Reputation: 77
I created a borderless form and I've been able to activate the form move event through this code:
[System.Runtime.InteropServices.DllImportAttribute("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
[System.Runtime.InteropServices.DllImportAttribute("user32.dll")]
public static extern bool ReleaseCapture();
private void FASTMain_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
ReleaseCapture();
SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
}
}
private void FASTMain_Move(object sender, EventArgs e)
{
WindowState = FormWindowState.Normal;
}
I would like to know if it is possible to intercept the mouse double-click event on the form as well.
Upvotes: 1
Views: 492
Reputation: 81620
Try checking for the e.Clicks value:
protected override void OnMouseDown(MouseEventArgs e) {
base.OnMouseDown(e);
if (e.Button == MouseButtons.Left) {
if (e.Clicks > 1) {
// do something with double-click
} else {
ReleaseCapture();
SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
}
}
}
Upvotes: 2