so I just expanded the glass area of my form into the client area with DwmExtendFrameIntoClientArea (Vista / 7 Aero stuff).
I have already sent a Windows message in the override Form class method OnMouseDown() causing the window to be movable with the glass area, as explained here Make a borderless form movable?.
However because of this, I am not receiving any form Click / MouseClick / DoubleClick etc. events when clicking on the expanded glass area.
I actually want the form to maximize when I double click the top expanded glass area, like normal titlebars do.
Here's the code of the Form-inheriting class:
protected override void OnMouseDown(MouseEventArgs e)
{
// Fensterverschiebung in Glass-Regionen
if (_glassMovable && e.Button == MouseButtons.Left
&& (e.X < _glassPadding.Left || e.X > Width - _glassPadding.Right
|| e.Y < _glassPadding.Top || e.Y > Height - _glassPadding.Bottom))
{
NativeMethods.ReleaseCapture();
NativeMethods.SendMessage(Handle, NativeMethods.WM_NCLBUTTONDOWN,
NativeMethods.HT_CAPTION, 0);
}
base.OnMouseDown(e);
}
protected override void OnMouseDoubleClick(MouseEventArgs e)
{
// Fenstermaximierung / Minimierung in Glass-Regionen
if (MaximizeBox && e.Button == MouseButtons.Left && e.Y < _glassPadding.Top)
{
if (WindowState == FormWindowState.Normal)
{
WindowState = FormWindowState.Maximized;
}
else if (WindowState == FormWindowState.Maximized)
{
WindowState = FormWindowState.Normal;
}
}
base.OnMouseDoubleClick(e);
}
Is there any way to get this to work?
BoltClocks link to a solution for WPF inspired me for the following, similar code for WinForms.
I now override WndProc instead of the OnMouse* events.
The glass region behaves exactly like a title bar, e.g. drag'n'drop with dock support in Windows 7 and double click for maximizing / restoring. Additionally, this solution now supports the system window context menu when right clicking the glass area.