I'm trying to make my panel control movable using c#, but my main form moves along with the panel control when dragging. Is there a better code for this?
public const int WM_NCLBUTTONDOWN = 0xA1;
public const int HT_CAPTION = 0x2;
[DllImport("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
[DllImport("user32.dll")]
public static extern bool ReleaseCaptre();
public static void _MOVE_PANEL(IntPtr Handle, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
ReleaseCaptre();
SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
}
}
private void sub_inv_pcount_edit_MouseMove(object sender, MouseEventArgs e) //panel move
{
_MOVE_PANEL(Handle, e);
}
see sample: see screenshot