我也不知道为什么要自定义一个没差的WinForm,反正就是遇到了MyForm无法用鼠标拖着走的问题,百度到的解决方案,记录一下:再把
[DllImport("user32.dll")]
public static extern bool ReleaseCapture();
[DllImport("user32.dll")]
public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
public const int WM_SYSCOMMAND = 0x0112;
public const int SC_MOVE = 0xF010;
public const int HTCAPTION = 0x0002; private void tab_title_MouseDown(object sender, MouseEventArgs e)
{
ReleaseCapture();
SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, );//*********************调用移动无窗体控件函数
}
再把tab_title_MouseDown方法给任务栏的MouseDown事件注册进去就好了:
public LargeIcoMainForm()
{
InitializeComponent();
this.tab_title.MouseDown += new System.Windows.Forms.MouseEventHandler(this.tab_title_MouseDown);
}
完美。