private const int WM_NCHITTEST = 0x84; // Mouse capture.
private const int HTCLIENT = 0x1;      // Client area.
private const int HTCAPTION = 0x2;     // Title bar.
// This function intercepts all the commands sent to the application.
// It checks if user click (WM_NCHITTEST) on the form area (HTCLIENT)
// It fakes the result as the title bar (HTCAPTION)
// This makes the form thinks user clicked on the title bar.
// So we can click and move form by (fake) title bar.
protected override void WndProc(ref Message message)
{
    base.WndProc(ref message);
    if (message.Msg == WM_NCHITTEST && (int)message.Result == HTCLIENT)
    {
        message.Result = (IntPtr)HTCAPTION;
    }
} 
Showing posts with label no border. Show all posts
Showing posts with label no border. Show all posts
Monday, December 2, 2013
[Tutorial] Move form with no border
Just add the below snippet to your code (C#):
Subscribe to:
Comments (Atom)
