case Msg.WM_NCHITTEST:
int x = Control.LowOrder ((int) m.LParam.ToInt32 ());
int y = Control.HighOrder ((int) m.LParam.ToInt32 ());
-
- form.PointToClient (ref x, ref y);
+
+ NCPointToClient (ref x, ref y);
FormPos pos = FormPosForCoords (x, y);
}
return true;
+ // Return true from these guys, otherwise win32 will mess up z-order
case Msg.WM_NCLBUTTONUP:
- return HandleNCLButtonUp (ref m);
+ HandleNCLButtonUp (ref m);
+ return true;
case Msg.WM_NCLBUTTONDOWN:
- return HandleNCLButtonDown (ref m);
+ HandleNCLButtonDown (ref m);
+ return true;
case Msg.WM_NCLBUTTONDBLCLK:
HandleNCLButtonDblClick (ref m);
break;
case Msg.WM_NCPAINT:
- PaintDecorations ();
+ PaintEventArgs pe = XplatUI.PaintEventStart (form.Handle, false);
+
+ Rectangle clip;
+ // clip region is not correct on win32.
+ // if (m.WParam.ToInt32 () > 1) {
+ // Region r = Region.FromHrgn (m.WParam);
+ // RectangleF rf = r.GetBounds (pe.Graphics);
+ // clip = new Rectangle ((int) rf.X, (int) rf.Y, (int) rf.Width, (int) rf.Height);
+ //} else {
+ clip = new Rectangle (0, 0, form.Width, form.Height);
+ //}
+
+ ThemeEngine.Current.DrawManagedWindowDecorations (pe.Graphics, clip, this);
+ XplatUI.PaintEventEnd (form.Handle, false);
return true;
}
+
return false;
}
protected virtual void Activate ()
{
// Hack to get a paint
- NativeWindow.WndProc (form.Handle, Msg.WM_NCPAINT, IntPtr.Zero, IntPtr.Zero);
+ //NativeWindow.WndProc (form.Handle, Msg.WM_NCPAINT, IntPtr.Zero, IntPtr.Zero);
form.Refresh ();
}
return true;
}
+
private void FormSizeChangedHandler (object sender, EventArgs e)
{
ThemeEngine.Current.ManagedWindowSetButtonLocations (this);
-
- PaintDecorations ();
- }
-
- public void PaintDecorations ()
- {
- PaintEventArgs pe = XplatUI.PaintEventStart (form.Handle, false);
- ThemeEngine.Current.DrawManagedWindowDecorations (pe.Graphics, pe.ClipRectangle, this);
-
- if (IsMaximized) {
- MainMenu menu = form.ActiveMenu;
- DrawMaximizedButtons (menu, pe);
- if (menu != null)
- menu.Draw (pe);
- }
-
- XplatUI.PaintEventEnd (form.Handle, false);
+ Message m = new Message ();
+ m.Msg = (int) Msg.WM_NCPAINT;
+ m.HWnd = form.Handle;
+ m.LParam = IntPtr.Zero;
+ m.WParam = new IntPtr (1);
+ XplatUI.SendMessage (ref m);
}
protected void CreateButtons ()
int x = Control.LowOrder ((int) m.LParam.ToInt32 ());
int y = Control.HighOrder ((int) m.LParam.ToInt32 ());
- Console.WriteLine ("MOUSE DOWN: ({0}, {1})", x, y);
- form.PointToClient (ref x, ref y);
// Need to adjust because we are in NC land
+ NCPointToClient (ref x, ref y);
FormPos pos = FormPosForCoords (x, y);
-
if (pos == FormPos.TitleBar) {
HandleTitleBarDown (x, y);
protected virtual void HandleTitleBarDown (int x, int y)
{
foreach (TitleButton button in title_buttons) {
- Console.WriteLine ("BUTTON RECTANGLE: {0}", button.Rectangle);
if (button != null && button.Rectangle.Contains (x, y)) {
button.State = ButtonState.Pushed;
return;
form.Capture = false;
state = State.Idle;
+ if (form.MdiContainer != null)
+ form.MdiContainer.SizeScrollBars();
}
int x = Control.LowOrder ((int) m.LParam.ToInt32 ());
int y = Control.HighOrder ((int) m.LParam.ToInt32 ());
- form.PointToClient (ref x, ref y);
+ NCPointToClient (ref x, ref y);
foreach (TitleButton button in title_buttons) {
if (button != null && button.Rectangle.Contains (x, y)) {
{
}
+ protected virtual void NCPointToClient(ref int x, ref int y) {
+ form.PointToClient(ref x, ref y);
+ y += TitleBarHeight;
+ y += ThemeEngine.Current.ManagedWindowBorderWidth (this);
+ }
+
protected FormPos FormPosForCoords (int x, int y)
{
int bw = ThemeEngine.Current.ManagedWindowBorderWidth (this);