Casey Kramer wrote:
Okay, here goes (see code sample below):
<Code snipped>
Or you can override the WndProc method of the form. This should only
be used with captionless forms as it will interpret the clicking of the
close button [x] in the corner as moving the form. What it does is
trick Windows into thinking you have the mouse cursor
//C# code
protected override void WndProc(ref Message m)
{
const int WmNcHitTest = 0x84;
const int HtCaption = 2;
if (m.Msg == WmNcHitTest)
m.Result = new IntPtr(HtCaptio n);
else
base.WndProc(re f m);
}
'VB Code
Protected Overrides Sub WndProc(ByRef m As
System.Windows. Forms.Message)
Const WmNcHitTest As Integer = &H84
Const HtCaption As Integer = &H2
Debug.WriteLine (m.ToString)
If m.Msg = WmNcHitTest Then
m.Result = New IntPtr(HtCaptio n)
Else
MyBase.WndProc( m)
End If
End Sub
If you want to click on another control, such as a panel, and move the
form, you can use similar code:
private void Panel1_MouseDow n(object sender, MouseEventArgs e)
{
const uint WM_SYSCOMMAND = 0x0112;
const uint SC_MOVE = 0xF010;
const int HtCaption = 2;
pnlAdmin.Captur e = false;
SendMessage(thi s.Handle, WM_SYSCOMMAND, new IntPtr(SC_MOVE +
HtCaption),new IntPtr(0));
}
Hope this helps