using System.Runtime.InteropServices; ............ public const int WM_NCLBUTTONDOWN = 0xA1; public const int HTCAPTION = 0x2; [DllImportAttribute ("user32.dll")] public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam); [DllImportAttribute ("user32.dll")] public static extern bool ReleaseCapture(); private void Form2_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { ReleaseCapture(); SendMessage(Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0); }
............
public const int WM_NCLBUTTONDOWN = 0xA1;
public const int HTCAPTION = 0x2; [DllImportAttribute ("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam); [DllImportAttribute ("user32.dll")]
public static extern bool ReleaseCapture(); private void Form2_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
ReleaseCapture();
SendMessage(Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0);
}
能不能移动某个控件然后带动其所在的窗体?
结果还要靠user32.dll所以有点惊讶,失态了!还想问个问题,那怎么用鼠标拉动边框改(应该要自己制作假边框)变窗体大小?