设置无边框 Form:
public Customize() { InitializeComponent(); this.FormBorderStyle = FormBorderStyle.None; }
通过重写 WndProc 实现无边框窗体的拖动:
private const int WM_NCHITTEST = 0x84;
private const int HTCLIENT = 0x1;
private const int HTCAPTION = 0x2;
// Implement the drag of the form
protected override void WndProc(ref Message message)
{
base.WndProc(ref message);
if (message.Msg == WM_NCHITTEST && (int)message.Result == HTCLIENT)
{
message.Result = (IntPtr)HTCAPTION;
}
}