Moving forms without caption bars

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form with the FormBorderStyle = None, i.e. no caption bar, no
borders. But I'd still like to have the possibility to move this form by
using the mouse. Could anybody tell me what to implement to accomplish this?

Thanks!

Bevo
 
Hello, "Bevo"
I have a form with the FormBorderStyle = None, i.e. no caption bar, no
borders. But I'd still like to have the possibility to move this form by
using the mouse. Could anybody tell me what to implement to accomplish this?

You can dispatch WM_NCHITTEST message and tell to Windows that user clicks on caption. Simply override WndProc method:

protected override void WndProc(ref Message m)
{
if (m.Msg == 0x0084) //WM_NCHITTEST
{
base.WndProc(ref m);

if (m.Result == (IntPtr)1) //HTCLIENT. User clicks on the window client area
{
m.Result = (IntPtr)2; //HTCAPTION. Now it's caption
}
}
else
{
base.WndProc(ref m);
}
}
 
Hi,

Well, that depend of what mouse action you want to be interpreted as a
"move window" action.

I think that winamp as a similar thing, if you click and drag the window it
does move it.
You can handle these events accordinly.

Then you may use Form.Location to reflect the mouse movement.

Cheers,
 
Back
Top