问题
Possible Duplicate:
C# - Make a borderless form movable?
If I set my form's FormBorderStyle to None, I lose the drag behavior of the form, as expected.
I've added a custom bar to the top of my form and I like it to stay that way, now is it possible to keep the form in this mode and have (or write) drag behavior?
If it's possible, how should I do so. I really hope to find a Yes it's possible answer. :)
回答1:
private const Int32 WM_NCHITTEST = 0x84;
private const Int32 HTCLIENT = 0x1;
private const Int32 HTCAPTION = 0x2;
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_NCHITTEST)
{
base.WndProc(ref m);
if ((Int32)m.Result == HTCLIENT)
m.Result = (IntPtr)HTCAPTION;
return;
}
base.WndProc(ref m);
}
来源:https://stackoverflow.com/questions/14363162/add-drag-behavior-to-a-form-with-formborderstyle-set-to-none