C# 利用消息机制实现可拖动 lable

View Code
 1         [DllImport("User32.DLL")]
 2         public static extern int SendMessage(IntPtr hWnd, uint Msg, int wParam, int lParam);
 3         [DllImport("User32.DLL")]
 4         public static extern bool ReleaseCapture();
 5         public const uint WM_SYSCOMMAND = 0x0112;
 6         public const int SC_MOVE = 61456;
 7         public const int HTCAPTION = 2;
 8 
 9         private void label1_MouseDown(object sender, MouseEventArgs e)
10         {
11             ReleaseCapture();
12             SendMessage(((Label)sender).Handle, WM_SYSCOMMAND, SC_MOVE | HTCAPTION, 0);
13         }
posted @ 2012-09-27 17:33  Lyle Blog  阅读(308)  评论(1)    收藏  举报