void FrmMain_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
ReleaseCapture(); //窗体移动 捕获鼠标
SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + ACCAPTION, 0);
}
}
[DllImport("user32.dll")]
public static extern bool ReleaseCapture();//窗体移动
[DllImport("user32.dll")]
public static extern bool SendMessage(IntPtr MouseMsg, int wMsg, int wParam, int iParam);
public const int WM_SYSCOMMAND = 0x0112; //接收窗体按钮的消息
public const int SC_MOVE = 0xf010;
private ComponentFactory.Krypton.Toolkit.KryptonButton kbEsc;
private ComponentFactory.Krypton.Toolkit.KryptonButton kryptonButton3;
private ComponentFactory.Krypton.Toolkit.KryptonRichTextBox rthMain; //移动窗体
public const int ACCAPTION = 0x0002; //移动无边窗体的消息
《这个方法并不是自己写的 是在网上找到的较好的方法,之前弄的是写3个事件的,但是效果没这个好 所以推荐下...》