Click here to Skip to main content
Click here to Skip to main content

Tagged as

Go to top

Moveable non-standard shape form

, 19 Dec 2010
Rate this:
Please Sign up or sign in to vote.
Trick for dragging the form while clicking on the client area
This is a trick for dragging the form while clicking on the client area (assuming that the header of the form is removed).
 
public const int WM_NCLBUTTONDOWN = 0xA1;
public const int HT_CAPTION = 0x2;
 
[DllImportAttribute("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
[DllImportAttribute("user32.dll")]
public static extern bool ReleaseCapture();
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
    if (e.Button == MouseButtons.Left)
    {
         ReleaseCapture();
         SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
    }
}

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

tumbledDown2earth
Software Developer
India India
is a poor software developer and thinker. Presently working on a theory of "complementary perception". It's a work in progress.

Comments and Discussions

 
GeneralIf you do that, how do you allow clicking on the form withou... PinsubeditorWalt Fair, Jr.10-Dec-10 9:51 
GeneralMhm. PinmemberVercas13-Dec-10 8:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web02 | 2.8.140916.1 | Last Updated 19 Dec 2010
Article Copyright 2010 by tumbledDown2earth
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid