Advertisement
Guest User

Untitled

a guest
Feb 27th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. using System;
  2. using System.Drawing;
  3. using System.Windows.Forms;
  4. using System.Drawing.Drawing2D;
  5. using System.Runtime.InteropServices;
  6.  
  7.  
  8. namespace WindowsFormsApplication3
  9. {
  10. public partial class Form1 : Form
  11. {
  12.  
  13. [DllImport("Gdi32.dll", EntryPoint = "CreateRoundRectRgn")]
  14. private static extern IntPtr CreateRoundRectRgn
  15. (
  16. int nLeftRect, // x-coordinate of upper-left corner
  17. int nTopRect, // y-coordinate of upper-left corner
  18. int nRightRect, // x-coordinate of lower-right corner
  19. int nBottomRect, // y-coordinate of lower-right corner
  20. int nWidthEllipse, // height of ellipse
  21. int nHeightEllipse // width of ellipse
  22. );
  23.  
  24. public Form1()
  25. {
  26. InitializeComponent();
  27. Region = System.Drawing.Region.FromHrgn(CreateRoundRectRgn(0, 0, Width, Height, 5, 5));
  28. }
  29.  
  30. protected override void OnLoad(EventArgs e)
  31. {
  32. base.OnLoad(e);
  33. this.FormBorderStyle = FormBorderStyle.None;
  34. }
  35.  
  36. protected override void OnPaintBackground(PaintEventArgs e)
  37. {
  38. using (LinearGradientBrush brush = new LinearGradientBrush(this.ClientRectangle,
  39. Color.LawnGreen,
  40. Color.Green,
  41. 90F))
  42. {
  43. e.Graphics.FillRectangle(brush, this.ClientRectangle);
  44. }
  45. }
  46.  
  47.  
  48. public const int WM_NCLBUTTONDOWN = 0xA1;
  49. public const int HT_CAPTION = 0x2;
  50.  
  51. [System.Runtime.InteropServices.DllImportAttribute("user32.dll")]
  52. public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
  53. [System.Runtime.InteropServices.DllImportAttribute("user32.dll")]
  54. public static extern bool ReleaseCapture();
  55.  
  56. private void Form1_Load(object sender, EventArgs e)
  57. {
  58.  
  59. }
  60.  
  61. private void Form1_MouseDown_1(object sender, MouseEventArgs e)
  62. {
  63. if (e.Button == MouseButtons.Left)
  64. {
  65. ReleaseCapture();
  66. SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
  67. }
  68. }
  69.  
  70. private void button1_Click(object sender, EventArgs e)
  71. {
  72. this.Close();
  73. }
  74. }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement