If you want the part of the form to behave like a signature, the WM_NCHITTEST trick that WM_NCHITTEST gave is the way to go. But if you want to make a child window, you can drag the form, and there is another way.
Basically, if you send the WM_SYSCOMMAND message to DefWindowProc with the MOUSE_MOVE command identifier, then Windows will go into drag and drop mode. Basically, as the signature does, but by cutting out the middle person, we can initiate this drag from the child window, and we do not get all the other actions of the label.
public class form1 : Form { ... [DllImport("user32.dll")] static extern IntPtr DefWindowProc(IntPtr hWnd, uint uMsg, UIntPtr wParam, IntPtr lParam); [DllImport("user32.dll")] static extern bool ReleaseCapture(IntPtr hwnd); const uint WM_SYSCOMMAND = 0x112; const uint MOUSE_MOVE = 0xF012; public void DragMe() { DefWindowProc(this.Handle, WM_SYSCOMMAND, (UIntPtr)MOUSE_MOVE, IntPtr.Zero); } private void button1_MouseDown(object sender, MouseEventArgs e) { Control ctl = sender as Control;
John knoeller
source share