Advertisement
njunwa1

Drop and borderless form

Mar 9th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.67 KB | None | 0 0
  1.  
  2. using System.Runtime.InteropServices;
  3.  
  4. public const int WM_NCLBUTTONDOWN = 0xA1;
  5. public const int HT_CAPTION = 0x2;
  6.  
  7. [DllImportAttribute("user32.dll")]
  8. public static extern int SendMessage(IntPtr hWnd,
  9.                  int Msg, int wParam, int lParam);
  10. [DllImportAttribute("user32.dll")]
  11. public static extern bool ReleaseCapture();
  12.  
  13.  
  14. //Then put the following two lines of code in the form's MouseDown event like this:
  15.  
  16. private void Form1_MouseDown(object sender,
  17.         System.Windows.Forms.MouseEventArgs e)
  18. {    
  19.     if (e.Button == MouseButtons.Left)
  20.     {
  21.         ReleaseCapture();
  22.         SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement