1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| using System.Runtime.InteropServices;
private const int HTCAPTION = 0x2;
private const int WM_NCLBUTTONDOWN = 0xA1;
[DllImport("User32.dll")]
public static extern bool ReleaseCapture();
[DllImport("User32.dll")]
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
private void panel1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
ReleaseCapture();
SendMessage(this.panel1.Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0);
}
} |