- // 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);
+
+ if (form.ActiveMenu != null) {
+ Point pnt;
+
+ pnt = GetMenuOrigin ();
+
+ // The entire menu has to be in the clip rectangle because the
+ // control buttons are right-aligned and otherwise they would
+ // stay painted when the window gets resized.
+ clip = new Rectangle (pnt.X, pnt.Y, form.ClientSize.Width, 0);
+ clip = Rectangle.Union (clip, pe.ClipRectangle);
+ pe.SetClip (clip);
+ pe.Graphics.SetClip (clip);
+
+ form.ActiveMenu.Draw (pe, new Rectangle (pnt.X, pnt.Y, form.ClientSize.Width, 0));
+ }
+ if (HasBorders || IsMinimized && !(Form.IsMdiChild && IsMaximized)) {
+ // clip region is not correct on win32.
+ // use the entire form's area.
+ clip = new Rectangle (0, 0, form.Width, form.Height);
+ ThemeEngine.Current.DrawManagedWindowDecorations (pe.Graphics, clip, this);
+ }
+ XplatUI.PaintEventEnd (ref m, form.Handle, false);