Take the 2-minute tour ×

I am trying to move c# form without title bar. I found an article about it on http://www.codeproject.com/KB/cs/csharpmovewindow.aspx

it works as long as I do not set FormBorderStyle as "None". It does not work when I set FormBorderStyle to "None".

Is there a way to make it work with FormBorderStyle "None" ?

share|improve this question
It works for me with FormBorderStyle set to None. This is on Server 2008, VS2008 with .NET 3.5. What .NET version and OS are you on? –  Michael McCloskey Aug 6 '09 at 22:28
@Michael McCloskey - I am using windows 7 rc, vs2008 with .net 3.5. –  Moon Aug 6 '09 at 22:35
@Michael McClosKey - nevermind! it works now. I do not know what happened. –  Moon Aug 6 '09 at 22:36
add comment

3 Answers

up vote 16 down vote accepted

I know this question is over a year old, but I was searching trying to remember how I've done it in the past. So for anyone else's reference, the quickest and less complex way then the above link is to override the WndProc function.

Constants in Windows API
0x84 = WM_NCHITTEST - Mouse Capture Test
0x1 = HTCLIENT - Application Client Area
0x2 = HTCAPTION - Application Title Bar

This function intercepts all the commands sent to the application. 
It checks to see of the message is a mouse click in the application. 
It passes the action to the base action by default. It reassigns 
the action to the title bar if it occured in the client area
to allow the drag and move behavior.

protected override void WndProc(ref Message m)
        case 0x84:
            base.WndProc(ref m);
            if ((int)m.Result == 0x1)
                m.Result = (IntPtr)0x2;

    base.WndProc(ref m);

This will allow any form to be moved by clicking and dragging within the client area.

share|improve this answer
can you explain this a bit –  masfenix Aug 4 '10 at 21:14
Added some detail about what it does –  ShaneB Aug 4 '10 at 21:28
why can't i drag the form when mousedown event is on menuStrip? –  CMA Aug 17 '12 at 7:02
The code above only checks if the mousedown event is in the client area (0x1) HTCLIENT. If you want to check a menuStrip try (0x5) HTMENU. –  ShaneB Aug 28 '12 at 23:10
add comment

Here it is the best way I have found. It is a ".NET way", wihout using WndProc. You just have to handle the MouseDown, MouseMove and MouseUp events of the surfaces you want to be draggable.

private bool dragging = false;
private Point dragCursorPoint;
private Point dragFormPoint;

private void FormMain_MouseDown(object sender, MouseEventArgs e)
    dragging = true;
    dragCursorPoint = Cursor.Position;
    dragFormPoint = this.Location;

private void FormMain_MouseMove(object sender, MouseEventArgs e)
    if (dragging)
        Point dif = Point.Subtract(Cursor.Position, new Size(dragCursorPoint));
        this.Location = Point.Add(dragFormPoint, new Size(dif));

private void FormMain_MouseUp(object sender, MouseEventArgs e)
    dragging = false;
share|improve this answer
+1 Worked for me. –  blak3r May 24 '11 at 21:27
works like magic! is there any catch? Any delay during the process as compared to using WndProc? –  Charmie Jul 3 '13 at 7:37
Work like charm! great concept.. –  Moxet Jan Jan 9 at 7:45
This is the primary answer on SO for the .NET way. Thanks. –  Sabuncu 2 days ago
add comment

You can right-click your app's taskbar button and click 'move'.

share|improve this answer
add comment

Your Answer


