Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. private const int WM_NCHITTEST = 0x84;
  2. private const int HT_CLIENT = 0x1;
  3. private const int HT_CAPTION = 0x2;
  4.  
  5. [DllImportAttribute("user32.dll")]
  6. public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
  7. [DllImportAttribute("user32.dll")]
  8. public static extern bool ReleaseCapture();
  9.  
  10.  
  11. protected override void WndProc(ref Message m)
  12. {
  13. base.WndProc(ref m);
  14. if (m.Msg == WM_NCHITTEST)
  15. m.Result = (IntPtr)(HT_CAPTION);
  16. }
  17.  
  18. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
  19.  
  20. public const int WM_NCLBUTTONDOWN = 0xA1;
  21. public const int HT_CAPTION = 0x2;
  22.  
  23. [DllImportAttribute("user32.dll")]
  24. public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
  25. [DllImportAttribute("user32.dll")]
  26. public static extern bool ReleaseCapture();
  27.  
  28. private void Form1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
  29. {
  30. if (e.Button == MouseButtons.Left)
  31. {
  32. ReleaseCapture();
  33. SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement