1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 // Copyright (c) 2004-2006 Novell, Inc.
23 // Peter Bartok pbartok@novell.com
30 using System
.ComponentModel
;
31 using System
.ComponentModel
.Design
;
32 using System
.ComponentModel
.Design
.Serialization
;
33 using System
.Collections
;
34 using System
.Runtime
.InteropServices
;
35 using System
.Threading
;
37 namespace System
.Windows
.Forms
{
38 [DesignerCategory("Form")]
39 [DesignTimeVisible(false)]
40 [Designer("System.Windows.Forms.Design.FormDocumentDesigner, " + Consts
.AssemblySystem_Design
, typeof(IRootDesigner
))]
41 [DefaultEvent("Load")]
43 public class Form
: ContainerControl
{
44 #region Local Variables
45 internal static Form active_form
;
46 internal bool closing
;
47 FormBorderStyle form_border_style
;
48 private bool autoscale
;
49 private Size clientsize_set
;
50 private Size autoscale_base_size
;
51 private bool allow_transparency
;
52 private static Icon default_icon
;
53 internal bool is_modal
;
54 internal FormWindowState window_state
;
55 private bool control_box
;
56 private bool minimize_box
;
57 private bool maximize_box
;
58 private bool help_button
;
59 private bool show_in_taskbar
;
61 private IButtonControl accept_button
;
62 private IButtonControl cancel_button
;
63 private DialogResult dialog_result
;
64 private FormStartPosition start_position
;
66 private Form
.ControlCollection owned_forms
;
67 private MdiClient mdi_container
;
68 internal InternalWindowManager window_manager
;
69 private Form mdi_parent
;
70 private bool key_preview
;
71 private MainMenu menu
;
73 private Size maximum_size
;
74 private Size minimum_size
;
75 private SizeGripStyle size_grip_style
;
76 private Rectangle maximized_bounds
;
77 private Rectangle default_maximized_bounds
;
78 private double opacity
;
79 internal ApplicationContext context
;
80 Color transparency_key
;
81 internal MenuTracker active_tracker
;
83 #endregion // Local Variables
85 #region Private & Internal Methods
88 default_icon
= (Icon
)Locale
.GetResource("mono.ico");
91 // warning: this is only hooked up when an mdi container is created.
92 private void ControlAddedHandler (object sender
, ControlEventArgs e
)
94 if (mdi_container
!= null) {
95 Console
.WriteLine ("SENDING TO BACK");
96 mdi_container
.SendToBack ();
99 #endregion // Private & Internal Methods
101 #region Public Classes
102 public new class ControlCollection
: Control
.ControlCollection
{
105 public ControlCollection(Form owner
) : base(owner
) {
106 this.form_owner
= owner
;
109 public override void Add(Control
value) {
110 if (Contains (value))
113 ((Form
)value).owner
=(Form
)owner
;
116 public override void Remove(Control
value) {
117 ((Form
)value).owner
= null;
121 #endregion // Public Classes
123 #region Public Constructor & Destructor
126 SizeF current_scale
= GetAutoScaleSize (DeviceContext
, Font
);
129 autoscale_base_size
= new Size ((int)current_scale
.Width
, (int) current_scale
.Height
);
130 allow_transparency
= false;
133 dialog_result
= DialogResult
.None
;
134 start_position
= FormStartPosition
.WindowsDefaultLocation
;
135 form_border_style
= FormBorderStyle
.Sizable
;
136 window_state
= FormWindowState
.Normal
;
141 minimum_size
= Size
.Empty
;
142 maximum_size
= Size
.Empty
;
143 clientsize_set
= Size
.Empty
;
148 show_in_taskbar
= true;
149 ime_mode
= ImeMode
.NoControl
;
152 size_grip_style
= SizeGripStyle
.Auto
;
153 maximized_bounds
= Rectangle
.Empty
;
154 default_maximized_bounds
= Rectangle
.Empty
;
155 owned_forms
= new Form
.ControlCollection(this);
156 transparency_key
= Color
.Empty
;
158 #endregion // Public Constructor & Destructor
160 #region Public Static Properties
162 public static Form ActiveForm
{
166 active
= FromHandle(XplatUI
.GetActive());
168 if (active
!= null) {
169 if ( !(active
is Form
)) {
172 parent
= active
.Parent
;
173 while (parent
!= null) {
174 if (parent
is Form
) {
177 parent
= parent
.Parent
;
187 #endregion // Public Static Properties
189 #region Public Instance Properties
191 public IButtonControl AcceptButton
{
193 return accept_button
;
197 accept_button
= value;
203 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
204 public bool AllowTransparency
{
206 return allow_transparency
;
210 if (value == allow_transparency
) {
214 if (XplatUI
.SupportsTransparency()) {
215 allow_transparency
= value;
218 if (IsHandleCreated
) {
219 XplatUI
.SetWindowTransparency(Handle
, Opacity
, TransparencyKey
);
222 UpdateStyles(); // Remove the WS_EX_LAYERED style
229 [MWFCategory("Layout")]
230 public bool AutoScale
{
242 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
243 public virtual Size AutoScaleBaseSize
{
245 return autoscale_base_size
;
249 autoscale_base_size
= value;
254 public override bool AutoScroll
{
256 return base.AutoScroll
;
259 base.AutoScroll
= value;
263 public override Color BackColor
{
265 return base.BackColor
;
268 base.BackColor
= value;
273 public IButtonControl CancelButton
{
275 return cancel_button
;
279 cancel_button
= value;
283 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Visible
)]
285 public Size ClientSize
{
287 return base.ClientSize
;
291 base.ClientSize
= value;
296 [MWFCategory("Window Style")]
297 public bool ControlBox
{
303 if (control_box
!= value) {
311 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
312 public Rectangle DesktopBounds
{
314 return new Rectangle(Location
, Size
);
323 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
324 public Point DesktopLocation
{
335 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
336 public DialogResult DialogResult
{
338 return dialog_result
;
342 if (value < DialogResult
.None
|| value > DialogResult
.No
)
343 throw new InvalidEnumArgumentException ("value", (int) value,
344 typeof (DialogResult
));
346 dialog_result
= value;
353 [DefaultValue(FormBorderStyle
.Sizable
)]
355 [MWFCategory("Appearance")]
356 public FormBorderStyle FormBorderStyle
{
358 return form_border_style
;
361 form_border_style
= value;
363 if (window_manager
== null) {
364 if (IsHandleCreated
) {
365 XplatUI
.SetBorderStyle(window
.Handle
, form_border_style
);
368 window_manager
.UpdateBorderStyle (value);
375 [DefaultValue(false)]
376 [MWFCategory("Window Style")]
377 public bool HelpButton
{
383 if (help_button
!= value) {
392 [MWFCategory("Window Style")]
402 if (IsHandleCreated
) {
403 XplatUI
.SetIcon(Handle
, icon
== null ? default_icon
: icon
);
410 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
411 public bool IsMdiChild
{
413 return mdi_parent
!= null;
417 [DefaultValue(false)]
418 [MWFCategory("Window Style")]
419 public bool IsMdiContainer
{
421 return mdi_container
!= null;
425 if (value && mdi_container
== null) {
426 mdi_container
= new MdiClient ();
427 Controls
.Add(mdi_container
);
428 ControlAdded
+= new ControlEventHandler (ControlAddedHandler
);
429 mdi_container
.SendToBack ();
430 } else if (!value && mdi_container
!= null) {
431 Controls
.Remove(mdi_container
);
432 mdi_container
= null;
438 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
439 public Form ActiveMdiChild
{
443 return (Form
) mdi_container
.ActiveMdiChild
;
448 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
449 public bool IsRestrictedWindow
{
455 [DefaultValue(false)]
456 public bool KeyPreview
{
467 [MWFCategory("Window Style")]
468 public bool MaximizeBox
{
473 if (maximize_box
!= value) {
474 maximize_box
= value;
475 if (IsHandleCreated
) {
483 [DefaultValue("{Width=0, Height=0}")]
485 [RefreshProperties(RefreshProperties
.Repaint
)]
486 [MWFCategory("Layout")]
487 public Size MaximumSize
{
493 if (maximum_size
!= value) {
494 maximum_size
= value;
495 OnMaximumSizeChanged(EventArgs
.Empty
);
496 if (IsHandleCreated
) {
497 XplatUI
.SetWindowMinMax(Handle
, maximized_bounds
, minimum_size
, maximum_size
);
504 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
505 public Form
[] MdiChildren
{
507 if (mdi_container
!= null)
508 return mdi_container
.MdiChildren
;
515 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
516 public Form MdiParent
{
522 if (value != null && !value.IsMdiContainer
)
523 throw new ArgumentException ();
525 if (mdi_parent
!= null) {
526 mdi_parent
.MdiContainer
.Controls
.Remove (this);
531 window_manager
= new MdiWindowManager (this,
532 mdi_parent
.MdiContainer
);
533 mdi_parent
.MdiContainer
.Controls
.Add (this);
537 } else if (mdi_parent
!= null) {
540 // Create a new window manager
541 window_manager
= null;
542 FormBorderStyle
= form_border_style
;
549 internal MenuTracker ActiveTracker
{
550 get { return active_tracker; }
552 if (value == active_tracker
)
555 Capture
= value != null;
556 active_tracker
= value;
560 internal MdiClient MdiContainer
{
561 get { return mdi_container; }
564 internal InternalWindowManager WindowManager
{
565 get { return window_manager; }
569 [MWFCategory("Window Style")]
570 public MainMenu Menu
{
579 if (menu
!= null && !IsMdiChild
) {
582 if (IsHandleCreated
) {
583 XplatUI
.SetMenu (window
.Handle
, menu
);
586 if (clientsize_set
!= Size
.Empty
) {
587 SetClientSizeCore(clientsize_set
.Width
, clientsize_set
.Height
);
589 UpdateBounds (bounds
.X
, bounds
.Y
, bounds
.Width
, bounds
.Height
, ClientSize
.Width
, ClientSize
.Height
-
590 ThemeEngine
.Current
.CalcMenuBarSize (DeviceContext
, menu
, ClientSize
.Width
));
599 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
600 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
601 public MainMenu MergedMenu
{
603 if (!IsMdiChild
|| window_manager
== null)
605 return ((MdiWindowManager
) window_manager
).MergedMenu
;
609 // This is the menu in display and being used because of merging this can
610 // be different then the menu that is actually assosciated with the form
611 internal MainMenu ActiveMenu
{
616 if (IsMdiContainer
&& mdi_container
.Controls
.Count
> 0 &&
617 ((Form
) mdi_container
.Controls
[0]).WindowState
== FormWindowState
.Maximized
) {
618 MdiWindowManager wm
= (MdiWindowManager
) ((Form
) mdi_container
.Controls
[0]).WindowManager
;
619 return wm
.MaximizedMenu
;
622 Form amc
= ActiveMdiChild
;
623 if (amc
== null || amc
.Menu
== null)
625 return amc
.MergedMenu
;
629 internal MdiWindowManager ActiveMaximizedMdiChild
{
631 Form child
= ActiveMdiChild
;
634 if (child
.WindowManager
== null || child
.window_state
!= FormWindowState
.Maximized
)
636 return (MdiWindowManager
) child
.WindowManager
;
641 [MWFCategory("Window Style")]
642 public bool MinimizeBox
{
647 if (minimize_box
!= value) {
648 minimize_box
= value;
649 if (IsHandleCreated
) {
657 [DefaultValue("{Width=0, Height=0}")]
659 [RefreshProperties(RefreshProperties
.Repaint
)]
660 [MWFCategory("Layout")]
661 public Size MinimumSize
{
667 if (minimum_size
!= value) {
668 minimum_size
= value;
670 if ((Size
.Width
< value.Width
) || (Size
.Height
< value.Height
)) {
671 Size
= new Size(Math
.Max(Size
.Width
, value.Width
), Math
.Max(Size
.Height
, value.Height
));
675 OnMinimumSizeChanged(EventArgs
.Empty
);
676 if (IsHandleCreated
) {
677 XplatUI
.SetWindowMinMax(Handle
, maximized_bounds
, minimum_size
, maximum_size
);
684 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
692 [TypeConverter(typeof(OpacityConverter
))]
693 [MWFCategory("Window Style")]
694 public double Opacity
{
702 AllowTransparency
= true;
704 if (IsHandleCreated
) {
706 XplatUI
.SetWindowTransparency(Handle
, opacity
, TransparencyKey
);
713 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
714 public Form
[] OwnedForms
{
718 form_list
= new Form
[owned_forms
.Count
];
720 for (int i
=0; i
<owned_forms
.Count
; i
++) {
721 form_list
[i
] = (Form
)owned_forms
[i
];
729 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
736 if (owner
!= value) {
738 owner
.RemoveOwnedForm(this);
741 owner
.AddOwnedForm(this);
742 if (IsHandleCreated
) {
743 if (owner
!= null && owner
.IsHandleCreated
) {
744 XplatUI
.SetTopmost(this.window
.Handle
, owner
.window
.Handle
, true);
746 XplatUI
.SetTopmost(this.window
.Handle
, IntPtr
.Zero
, false);
754 [MWFCategory("Window Style")]
755 public bool ShowInTaskbar
{
757 return show_in_taskbar
;
760 if (show_in_taskbar
!= value) {
761 show_in_taskbar
= value;
762 if (IsHandleCreated
) {
770 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
782 [MonoTODO("Trigger something when GripStyle is set")]
783 [DefaultValue(SizeGripStyle
.Auto
)]
784 [MWFCategory("Window Style")]
785 public SizeGripStyle SizeGripStyle
{
787 return size_grip_style
;
791 size_grip_style
= value;
795 [DefaultValue(FormStartPosition
.WindowsDefaultLocation
)]
797 [MWFCategory("Layout")]
798 public FormStartPosition StartPosition
{
800 return start_position
;
804 if (start_position
== FormStartPosition
.WindowsDefaultLocation
) { // Only do this if it's not set yet
805 start_position
= value;
806 if (IsHandleCreated
) {
807 switch(start_position
) {
808 case FormStartPosition
.CenterParent
: {
813 case FormStartPosition
.CenterScreen
: {
818 case FormStartPosition
.Manual
: {
819 Left
= CreateParams
.X
;
820 Top
= CreateParams
.Y
;
834 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
835 [EditorBrowsable(EditorBrowsableState
.Never
)]
836 public int TabIndex
{
838 return base.TabIndex
;
842 base.TabIndex
= value;
847 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
848 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
849 public bool TopLevel
{
851 return GetTopLevel();
855 if (!value && IsMdiContainer
)
856 throw new ArgumentException ("MDI Container forms must be top level.");
861 [DefaultValue(false)]
862 [MWFCategory("Window Style")]
863 public bool TopMost
{
869 if (topmost
!= value) {
872 XplatUI
.SetTopmost(window
.Handle
, owner
!= null ? owner
.window
.Handle
: IntPtr
.Zero
, value);
877 [MWFCategory("Window Style")]
878 public Color TransparencyKey
{
880 return transparency_key
;
884 transparency_key
= value;
886 AllowTransparency
= true;
888 XplatUI
.SetWindowTransparency(Handle
, Opacity
, transparency_key
);
892 [DefaultValue(FormWindowState
.Normal
)]
893 [MWFCategory("Layout")]
894 public FormWindowState WindowState
{
896 if (IsHandleCreated
) {
898 if (window_manager
!= null)
899 return window_manager
.GetWindowState ();
902 window_state
= XplatUI
.GetWindowState(Handle
);
905 catch(NotSupportedException
) {
913 FormWindowState old_state
= window_state
;
914 window_state
= value;
915 if (IsHandleCreated
) {
917 if (window_manager
!= null) {
918 window_manager
.SetWindowState (old_state
, value);
923 XplatUI
.SetWindowState(Handle
, value);
926 catch(NotSupportedException
) {
932 #endregion // Public Instance Properties
934 #region Protected Instance Properties
935 protected override CreateParams CreateParams
{
937 CreateParams cp
= new CreateParams ();
940 cp
.ClassName
= XplatUI
.DefaultClassName
;
945 cp
.Parent
= IntPtr
.Zero
;
946 cp
.menu
= ActiveMenu
;
948 if (start_position
== FormStartPosition
.WindowsDefaultLocation
&& !IsMdiChild
) {
949 cp
.X
= unchecked((int)0x80000000);
950 cp
.Y
= unchecked((int)0x80000000);
958 cp
.Style
= (int)(WindowStyles
.WS_CLIPCHILDREN
| WindowStyles
.WS_CLIPSIBLINGS
);
961 cp
.Style
|= (int)(WindowStyles
.WS_CHILD
| WindowStyles
.WS_CAPTION
);
962 if (Parent
!= null) {
963 cp
.Parent
= Parent
.Handle
;
966 cp
.ExStyle
|= (int) (WindowExStyles
.WS_EX_WINDOWEDGE
| WindowExStyles
.WS_EX_MDICHILD
);
968 switch (FormBorderStyle
) {
969 case FormBorderStyle
.None
:
971 case FormBorderStyle
.FixedToolWindow
:
972 case FormBorderStyle
.SizableToolWindow
:
973 cp
.ExStyle
|= (int) WindowExStyles
.WS_EX_TOOLWINDOW
;
976 cp
.Style
|= (int) WindowStyles
.WS_OVERLAPPEDWINDOW
;
981 switch (FormBorderStyle
) {
982 case FormBorderStyle
.Fixed3D
: {
983 cp
.Style
|= (int)(WindowStyles
.WS_CAPTION
| WindowStyles
.WS_BORDER
);
984 cp
.ExStyle
|= (int)WindowExStyles
.WS_EX_CLIENTEDGE
;
988 case FormBorderStyle
.FixedDialog
: {
989 cp
.Style
|= (int)(WindowStyles
.WS_CAPTION
| WindowStyles
.WS_BORDER
);
990 cp
.ExStyle
|= (int)(WindowExStyles
.WS_EX_DLGMODALFRAME
);
994 case FormBorderStyle
.FixedSingle
: {
995 cp
.Style
|= (int)(WindowStyles
.WS_CAPTION
| WindowStyles
.WS_BORDER
);
999 case FormBorderStyle
.FixedToolWindow
: {
1000 cp
.Style
|= (int)(WindowStyles
.WS_CAPTION
| WindowStyles
.WS_BORDER
);
1001 cp
.ExStyle
|= (int)(WindowExStyles
.WS_EX_TOOLWINDOW
);
1005 case FormBorderStyle
.Sizable
: {
1006 cp
.Style
|= (int)(WindowStyles
.WS_BORDER
| WindowStyles
.WS_THICKFRAME
| WindowStyles
.WS_CAPTION
);
1010 case FormBorderStyle
.SizableToolWindow
: {
1011 cp
.Style
|= (int)(WindowStyles
.WS_BORDER
| WindowStyles
.WS_THICKFRAME
| WindowStyles
.WS_CAPTION
);
1012 cp
.ExStyle
|= (int)(WindowExStyles
.WS_EX_TOOLWINDOW
);
1016 case FormBorderStyle
.None
: {
1022 switch(window_state
) {
1023 case FormWindowState
.Maximized
: {
1024 cp
.Style
|= (int)WindowStyles
.WS_MAXIMIZE
;
1028 case FormWindowState
.Minimized
: {
1029 cp
.Style
|= (int)WindowStyles
.WS_MINIMIZE
;
1035 cp
.ExStyle
|= (int) WindowExStyles
.WS_EX_TOPMOST
;
1038 if (ShowInTaskbar
) {
1039 cp
.ExStyle
|= (int)WindowExStyles
.WS_EX_APPWINDOW
;
1043 cp
.Style
|= (int)WindowStyles
.WS_MAXIMIZEBOX
;
1047 cp
.Style
|= (int)WindowStyles
.WS_MINIMIZEBOX
;
1051 cp
.Style
|= (int)WindowStyles
.WS_SYSMENU
;
1054 if (HelpButton
&& !MaximizeBox
&& !MinimizeBox
) {
1055 cp
.ExStyle
|= (int)WindowExStyles
.WS_EX_CONTEXTHELP
;
1059 cp
.Style
|= (int)WindowStyles
.WS_VISIBLE
;
1061 if (Opacity
< 1.0 || TransparencyKey
!= Color
.Empty
) {
1062 cp
.ExStyle
|= (int)WindowExStyles
.WS_EX_LAYERED
;
1065 if (!is_enabled
&& context
== null) {
1066 cp
.Style
|= (int)(WindowStyles
.WS_DISABLED
);
1073 protected override ImeMode DefaultImeMode
{
1075 return ImeMode
.NoControl
;
1079 protected override Size DefaultSize
{
1081 return new Size (300, 300);
1085 protected Rectangle MaximizedBounds
{
1087 if (maximized_bounds
!= Rectangle
.Empty
) {
1088 return maximized_bounds
;
1090 return default_maximized_bounds
;
1094 maximized_bounds
= value;
1095 OnMaximizedBoundsChanged(EventArgs
.Empty
);
1096 if (IsHandleCreated
) {
1097 XplatUI
.SetWindowMinMax(Handle
, maximized_bounds
, minimum_size
, maximum_size
);
1101 #endregion // Protected Instance Properties
1103 #region Public Static Methods
1104 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
1105 public static SizeF
GetAutoScaleSize (Font font
)
1107 return XplatUI
.GetAutoScaleSize(font
);
1110 #endregion // Public Static Methods
1112 #region Public Instance Methods
1113 internal SizeF
GetAutoScaleSize (Graphics g
, Font font
)
1116 // The following constants come from the dotnet mailing list
1117 // discussion: http://discuss.develop.com/archives/wa.exe?A2=ind0203A&L=DOTNET&P=R3655
1119 // The magic number is "Its almost the length
1120 // of the string with a smattering added in
1121 // for compat with earlier code".
1124 string magic_string
= "The quick brown fox jumped over the lazy dog.";
1125 double magic_number
= 44.549996948242189;
1126 float width
= (float) (g
.MeasureString (magic_string
, font
).Width
/ magic_number
);
1128 return new SizeF (width
, font
.Height
);
1131 public void Activate() {
1134 // The docs say activate only activates if our app is already active
1135 active
= ActiveForm
;
1136 if ((active
!= null) && (this != active
)) {
1137 XplatUI
.Activate(window
.Handle
);
1141 public void AddOwnedForm(Form ownedForm
) {
1142 if (!owned_forms
.Contains(ownedForm
)) {
1143 owned_forms
.Add(ownedForm
);
1145 ownedForm
.Owner
= this;
1148 public void Close () {
1150 XplatUI
.SendMessage(this.Handle
, Msg
.WM_CLOSE
, IntPtr
.Zero
, IntPtr
.Zero
);
1154 public void LayoutMdi(MdiLayout
value) {
1155 if (mdi_container
!= null) {
1156 mdi_container
.LayoutMdi(value);
1160 public void RemoveOwnedForm(Form ownedForm
) {
1161 owned_forms
.Remove(ownedForm
);
1164 public void SetDesktopBounds(int x
, int y
, int width
, int height
) {
1165 DesktopBounds
= new Rectangle(x
, y
, width
, height
);
1168 public void SetDesktopLocation(int x
, int y
) {
1169 DesktopLocation
= new Point(x
, y
);
1172 public DialogResult
ShowDialog() {
1173 return ShowDialog(null);
1176 public DialogResult
ShowDialog(IWin32Window ownerWin32
) {
1180 IntPtr capture_window
;
1184 if (ownerWin32
!= null) {
1185 Control c
= Control
.FromHandle (ownerWin32
.Handle
);
1187 owner
= c
.TopLevelControl
as Form
;
1190 if (owner
== this) {
1191 throw new InvalidOperationException("The 'ownerWin32' cannot be the form being shown.");
1195 throw new InvalidOperationException("The form is already displayed as a modal dialog.");
1199 throw new InvalidOperationException("Already visible forms cannot be displayed as a modal dialog. Set the Visible property to 'false' prior to calling Form.ShowDialog.");
1203 throw new InvalidOperationException("Cannot display a disabled form as modal dialog.");
1206 if (TopLevelControl
!= this) {
1207 throw new InvalidOperationException("Can only display TopLevel forms as modal dialog.");
1211 // Can't do this, will screw us in the modal loop
1212 form_parent_window
.Parent
= this.owner
;
1215 // Release any captures
1216 XplatUI
.GrabInfo(out capture_window
, out confined
, out area
);
1217 if (capture_window
!= IntPtr
.Zero
) {
1218 XplatUI
.UngrabWindow(capture_window
);
1221 previous
= Form
.ActiveForm
;
1224 // Commented out; we instead let the Visible=true inside the runloop create the control
1225 // otherwise setting DialogResult inside any of the events that are triggered by the
1226 // create will not actually cause the form to not be displayed.
1227 // Leaving this comment here in case there was an actual purpose to creating the control
1229 if (!IsHandleCreated
) {
1234 Application
.RunLoop(true, new ApplicationContext(this));
1236 if (previous
!= null) {
1237 // Cannot use Activate(), it has a check for the current active window...
1238 XplatUI
.Activate(previous
.window
.Handle
);
1241 if (DialogResult
!= DialogResult
.None
) {
1242 return DialogResult
;
1244 DialogResult
= DialogResult
.Cancel
;
1245 return DialogResult
.Cancel
;
1248 public override string ToString() {
1249 return GetType().FullName
.ToString() + ", Text: " + Text
;
1251 #endregion // Public Instance Methods
1253 #region Protected Instance Methods
1254 protected void ActivateMdiChild(Form form
) {
1255 if (!IsMdiContainer
)
1257 mdi_container
.ActivateChild (form
);
1258 OnMdiChildActivate(EventArgs
.Empty
);
1261 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
1262 protected override void AdjustFormScrollbars(bool displayScrollbars
) {
1263 base.AdjustFormScrollbars (displayScrollbars
);
1266 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
1267 protected void ApplyAutoScaling()
1269 SizeF current_size_f
= GetAutoScaleSize (DeviceContext
, Font
);
1270 Size current_size
= new Size ((int) current_size_f
.Width
, (int) current_size_f
.Height
);
1274 if (current_size
== autoscale_base_size
)
1277 if (Environment
.GetEnvironmentVariable ("MONO_MWF_SCALING") == "disable"){
1278 Console
.WriteLine ("Not scaling");
1283 // I tried applying the Fudge height factor from:
1284 // http://blogs.msdn.com/mharsh/archive/2004/01/25/62621.aspx
1285 // but it makes things larger without looking better.
1287 if (current_size_f
.Width
!= AutoScaleBaseSize
.Width
) {
1288 dx
= current_size_f
.Width
/ AutoScaleBaseSize
.Width
+ 0.08f
;
1293 if (current_size_f
.Height
!= AutoScaleBaseSize
.Height
) {
1294 dy
= current_size_f
.Height
/ AutoScaleBaseSize
.Height
+ 0.08f
;
1301 AutoScaleBaseSize
= current_size
;
1304 protected void CenterToParent() {
1312 w
= DefaultSize
.Width
;
1318 h
= DefaultSize
.Height
;
1322 if (parent
!= null) {
1324 } else if (owner
!= null) {
1328 if (owner
!= null) {
1329 this.Location
= new Point(ctl
.Left
+ ctl
.Width
/ 2 - w
/2, ctl
.Top
+ ctl
.Height
/ 2 - h
/ 2);
1333 protected void CenterToScreen() {
1341 w
= DefaultSize
.Width
;
1347 h
= DefaultSize
.Height
;
1350 XplatUI
.GetDisplaySize(out DisplaySize
);
1351 this.Location
= new Point(DisplaySize
.Width
/ 2 - w
/ 2, DisplaySize
.Height
/ 2 - h
/ 2);
1354 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
1355 protected override Control
.ControlCollection
CreateControlsInstance() {
1356 return base.CreateControlsInstance ();
1359 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
1360 protected override void CreateHandle() {
1361 base.CreateHandle ();
1363 if (XplatUI
.SupportsTransparency()) {
1364 if (allow_transparency
) {
1365 XplatUI
.SetWindowTransparency(Handle
, Opacity
, TransparencyKey
);
1369 XplatUI
.SetWindowMinMax(window
.Handle
, maximized_bounds
, minimum_size
, maximum_size
);
1371 XplatUI
.SetIcon(window
.Handle
, icon
);
1374 if ((owner
!= null) && (owner
.IsHandleCreated
)) {
1375 XplatUI
.SetTopmost(window
.Handle
, owner
.window
.Handle
, true);
1378 if (owned_forms
.Count
> 0) {
1379 for (int i
= 0; i
< owned_forms
.Count
; i
++) {
1380 if (owned_forms
[i
].IsHandleCreated
) {
1381 XplatUI
.SetTopmost(owned_forms
[i
].window
.Handle
, window
.Handle
, true);
1388 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
1389 protected override void DefWndProc(ref Message m
) {
1390 base.DefWndProc (ref m
);
1393 protected override void Dispose(bool disposing
) {
1394 base.Dispose (disposing
);
1397 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
1398 protected virtual void OnActivated(EventArgs e
) {
1399 if (Activated
!= null) {
1404 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
1405 protected virtual void OnClosed(EventArgs e
) {
1406 if (Closed
!= null) {
1411 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
1412 protected virtual void OnClosing(System
.ComponentModel
.CancelEventArgs e
) {
1413 if (Closing
!= null) {
1418 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
1419 protected override void OnCreateControl() {
1420 base.OnCreateControl ();
1421 if (this.ActiveControl
== null) {
1424 // This visible hack is to work around CanSelect always being false if one of the parents
1425 // is not visible; and we by default create Form invisible...
1426 visible
= this.is_visible
;
1427 this.is_visible
= true;
1429 if (SelectNextControl(this, true, true, true, true) == false) {
1433 this.is_visible
= visible
;
1435 Select(ActiveControl
);
1439 XplatUI
.SetMenu(window
.Handle
, menu
);
1442 OnLoad(EventArgs
.Empty
);
1444 // Send initial location
1445 OnLocationChanged(EventArgs
.Empty
);
1447 if (IsMdiContainer
) {
1448 mdi_container
.LayoutMdi (MdiLayout
.Cascade
);
1452 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
1453 protected virtual void OnDeactivate(EventArgs e
) {
1454 if (Deactivate
!= null) {
1455 Deactivate(this, e
);
1459 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
1460 protected override void OnFontChanged(EventArgs e
) {
1461 base.OnFontChanged (e
);
1464 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
1465 protected override void OnHandleCreated(EventArgs e
) {
1466 XplatUI
.SetBorderStyle(window
.Handle
, form_border_style
);
1467 base.OnHandleCreated (e
);
1470 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
1471 protected override void OnHandleDestroyed(EventArgs e
) {
1472 base.OnHandleDestroyed (e
);
1475 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
1476 protected virtual void OnInputLanguageChanged(InputLanguageChangedEventArgs e
) {
1477 if (InputLanguageChanged
!=null) {
1478 InputLanguageChanged(this, e
);
1482 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
1483 protected virtual void OnInputLanguageChanging(InputLanguageChangingEventArgs e
) {
1484 if (InputLanguageChanging
!=null) {
1485 InputLanguageChanging(this, e
);
1489 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
1490 protected virtual void OnLoad(EventArgs e
) {
1492 ApplyAutoScaling ();
1501 switch (StartPosition
) {
1502 case FormStartPosition
.CenterScreen
:
1503 this.CenterToScreen();
1505 case FormStartPosition
.CenterParent
:
1506 this.CenterToParent ();
1508 case FormStartPosition
.Manual
:
1509 Left
= CreateParams
.X
;
1510 Top
= CreateParams
.Y
;
1516 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
1517 protected virtual void OnMaximizedBoundsChanged(EventArgs e
) {
1518 if (MaximizedBoundsChanged
!= null) {
1519 MaximizedBoundsChanged(this, e
);
1523 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
1524 protected virtual void OnMaximumSizeChanged(EventArgs e
) {
1525 if (MaximumSizeChanged
!= null) {
1526 MaximumSizeChanged(this, e
);
1530 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
1531 protected virtual void OnMdiChildActivate(EventArgs e
) {
1532 if (MdiChildActivate
!= null) {
1533 MdiChildActivate(this, e
);
1537 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
1538 protected virtual void OnMenuComplete(EventArgs e
) {
1539 if (MenuComplete
!= null) {
1540 MenuComplete(this, e
);
1544 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
1545 protected virtual void OnMenuStart(EventArgs e
) {
1546 if (MenuStart
!= null) {
1551 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
1552 protected virtual void OnMinimumSizeChanged(EventArgs e
) {
1553 if (MinimumSizeChanged
!= null) {
1554 MinimumSizeChanged(this, e
);
1558 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
1559 protected override void OnPaint (PaintEventArgs pevent
) {
1560 base.OnPaint (pevent
);
1563 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
1564 protected override void OnResize(EventArgs e
) {
1568 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
1569 protected override void OnStyleChanged(EventArgs e
) {
1570 base.OnStyleChanged (e
);
1573 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
1574 protected override void OnTextChanged(EventArgs e
) {
1575 base.OnTextChanged (e
);
1578 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
1579 protected override void OnVisibleChanged(EventArgs e
) {
1580 base.OnVisibleChanged (e
);
1583 protected override bool ProcessCmdKey(ref Message msg
, Keys keyData
) {
1584 if (base.ProcessCmdKey (ref msg
, keyData
)) {
1588 // Give our menu a shot
1589 if (ActiveMenu
!= null) {
1590 return ActiveMenu
.ProcessCmdKey(ref msg
, keyData
);
1596 // LAMESPEC - Not documented that Form overrides ProcessDialogChar; class-status showed
1597 [EditorBrowsable (EditorBrowsableState
.Advanced
)]
1598 protected override bool ProcessDialogChar(char charCode
) {
1599 return base.ProcessDialogChar (charCode
);
1602 protected override bool ProcessDialogKey(Keys keyData
) {
1603 if ((keyData
& Keys
.Modifiers
) == 0) {
1604 if (keyData
== Keys
.Enter
&& accept_button
!= null) {
1605 accept_button
.PerformClick();
1607 } else if (keyData
== Keys
.Escape
&& cancel_button
!= null) {
1608 cancel_button
.PerformClick();
1612 return base.ProcessDialogKey(keyData
);
1615 protected override bool ProcessKeyPreview(ref Message msg
) {
1617 if (ProcessKeyEventArgs(ref msg
)) {
1621 return base.ProcessKeyPreview (ref msg
);
1624 protected override bool ProcessTabKey(bool forward
) {
1625 return SelectNextControl(ActiveControl
, forward
, true, true, true);
1628 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
1629 protected override void ScaleCore(float dx
, float dy
) {
1633 // We can't scale max or min windows
1634 if (WindowState
== FormWindowState
.Normal
) {
1635 // We cannot call base since base also adjusts X/Y, but
1636 // a form is toplevel and doesn't move
1640 if (!GetStyle(ControlStyles
.FixedWidth
)) {
1641 size
.Width
= (int)(size
.Width
* dx
);
1644 if (!GetStyle(ControlStyles
.FixedHeight
)) {
1645 size
.Height
= (int)(size
.Height
* dy
);
1651 /* Now scale our children */
1652 Control
[] controls
= child_controls
.GetAllControls ();
1653 for (int i
=0; i
< controls
.Length
; i
++) {
1654 controls
[i
].Scale(dx
, dy
);
1663 protected override void Select(bool directed
, bool forward
) {
1667 base.SelectNextControl(null, forward
, true, true, true);
1670 parent
= this.ParentForm
;
1671 if (parent
!= null) {
1672 parent
.ActiveControl
= this;
1678 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
1679 protected override void SetBoundsCore(int x
, int y
, int width
, int height
, BoundsSpecified specified
) {
1680 base.SetBoundsCore (x
, y
, width
, height
, specified
);
1683 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
1684 protected override void SetClientSizeCore(int x
, int y
) {
1685 if ((minimum_size
.Width
!= 0) && (x
< minimum_size
.Width
)) {
1686 x
= minimum_size
.Width
;
1687 } else if ((maximum_size
.Width
!= 0) && (x
> maximum_size
.Width
)) {
1688 x
= maximum_size
.Width
;
1691 if ((minimum_size
.Height
!= 0) && (y
< minimum_size
.Height
)) {
1692 y
= minimum_size
.Height
;
1693 } else if ((maximum_size
.Height
!= 0) && (y
> maximum_size
.Height
)) {
1694 y
= maximum_size
.Height
;
1697 Rectangle ClientRect
= new Rectangle(0, 0, x
, y
);
1698 Rectangle WindowRect
;
1699 CreateParams cp
= this.CreateParams
;
1701 clientsize_set
= new Size(x
, y
);
1704 if (XplatUI
.CalculateWindowRect(ref ClientRect
, cp
.Style
, cp
.ExStyle
, cp
.menu
, out WindowRect
)) {
1705 SetBoundsCore(bounds
.X
, bounds
.Y
, WindowRect
.Width
, WindowRect
.Height
, BoundsSpecified
.Size
);
1708 if (XplatUI
.CalculateWindowRect(ref ClientRect
, cp
.Style
, cp
.ExStyle
, cp
.menu
, out WindowRect
)) {
1709 SetBoundsCore(bounds
.X
, bounds
.Y
, WindowRect
.Width
, WindowRect
.Height
, BoundsSpecified
.Size
);
1714 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
1715 protected override void SetVisibleCore(bool value) {
1716 base.SetVisibleCore (value);
1719 protected override void UpdateDefaultButton() {
1720 base.UpdateDefaultButton ();
1723 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
1724 protected override void WndProc(ref Message m
) {
1726 if (window_manager
!= null && window_manager
.HandleMessage (ref m
)) {
1730 bool native_enabled
= XplatUI
.IsEnabled (Handle
);
1732 switch((Msg
)m
.Msg
) {
1733 case Msg
.WM_DESTROY
: {
1734 base.WndProc(ref m
);
1735 if (!is_recreating
) {
1736 this.closing
= true;
1741 case Msg
.WM_CLOSE_INTERNAL
: {
1746 case Msg
.WM_CLOSE
: {
1747 Form act
= Form
.ActiveForm
;
1748 if (act
!= null && act
!= this && act
.Modal
== true) {
1752 CancelEventArgs args
= new CancelEventArgs ();
1754 if (mdi_container
!= null) {
1755 foreach (Form mdi_child
in mdi_container
.MdiChildren
) {
1756 mdi_child
.OnClosing (args
);
1763 OnClosed (EventArgs
.Empty
);
1770 OnClosed (EventArgs
.Empty
);
1773 DialogResult
= DialogResult
.None
;
1780 case Msg
.WM_WINDOWPOSCHANGED
: {
1781 if (WindowState
!= FormWindowState
.Minimized
) {
1782 base.WndProc(ref m
);
1787 case Msg
.WM_ACTIVATE
: {
1788 if (m
.WParam
!= (IntPtr
)WindowActiveFlags
.WA_INACTIVE
) {
1789 OnActivated(EventArgs
.Empty
);
1791 OnDeactivate(EventArgs
.Empty
);
1796 case Msg
.WM_KILLFOCUS
: {
1797 base.WndProc(ref m
);
1801 case Msg
.WM_SETFOCUS
: {
1802 if (ActiveControl
!= null && ActiveControl
!= this) {
1803 ActiveControl
.Focus();
1804 return; // FIXME - do we need to run base.WndProc, even though we just changed focus?
1806 base.WndProc(ref m
);
1811 case Msg
.WM_NCLBUTTONDOWN
: {
1812 if (native_enabled
&& ActiveMenu
!= null) {
1813 ActiveMenu
.OnMouseDown(this, new MouseEventArgs (FromParamToMouseButtons ((int) m
.WParam
.ToInt32()), mouse_clicks
, Control
.MousePosition
.X
, Control
.MousePosition
.Y
, 0));
1816 if (ActiveMaximizedMdiChild
!= null) {
1817 ActiveMaximizedMdiChild
.HandleMenuMouseDown (ActiveMenu
,
1818 LowOrder ((int) m
.LParam
.ToInt32 ()),
1819 HighOrder ((int) m
.LParam
.ToInt32 ()));
1821 base.WndProc(ref m
);
1825 case Msg
.WM_NCMOUSEMOVE
: {
1826 if (native_enabled
&& ActiveMenu
!= null) {
1827 ActiveMenu
.OnMouseMove(this, new MouseEventArgs (FromParamToMouseButtons ((int) m
.WParam
.ToInt32()), mouse_clicks
, LowOrder ((int) m
.LParam
.ToInt32 ()), HighOrder ((int) m
.LParam
.ToInt32 ()), 0));
1829 base.WndProc(ref m
);
1833 case Msg
.WM_NCPAINT
: {
1834 if (ActiveMenu
!= null) {
1838 pe
= XplatUI
.PaintEventStart(Handle
, false);
1839 pnt
= XplatUI
.GetMenuOrigin(window
.Handle
);
1841 ActiveMenu
.Draw (pe
, new Rectangle (pnt
.X
, pnt
.Y
, ClientSize
.Width
, 0));
1843 if (ActiveMaximizedMdiChild
!= null) {
1844 ActiveMaximizedMdiChild
.DrawMaximizedButtons (ActiveMenu
, pe
);
1847 XplatUI
.PaintEventEnd(Handle
, false);
1850 base.WndProc(ref m
);
1854 case Msg
.WM_NCCALCSIZE
: {
1855 XplatUIWin32
.NCCALCSIZE_PARAMS ncp
;
1857 if ((ActiveMenu
!= null) && (m
.WParam
== (IntPtr
)1)) {
1858 ncp
= (XplatUIWin32
.NCCALCSIZE_PARAMS
)Marshal
.PtrToStructure(m
.LParam
, typeof(XplatUIWin32
.NCCALCSIZE_PARAMS
));
1861 ncp
.rgrc1
.top
+= ThemeEngine
.Current
.CalcMenuBarSize (DeviceContext
, ActiveMenu
, ncp
.rgrc1
.right
- ncp
.rgrc1
.left
);
1862 Marshal
.StructureToPtr(ncp
, m
.LParam
, true);
1868 case Msg
.WM_MOUSEMOVE
: {
1869 if (native_enabled
&& active_tracker
!= null) {
1870 MouseEventArgs args
;
1872 args
= new MouseEventArgs (FromParamToMouseButtons ((int) m
.WParam
.ToInt32()),
1873 mouse_clicks
, LowOrder ((int) m
.LParam
.ToInt32 ()), HighOrder ((int) m
.LParam
.ToInt32 ()), 0);
1874 active_tracker
.OnMotion(new MouseEventArgs (args
.Button
, args
.Clicks
, Control
.MousePosition
.X
, Control
.MousePosition
.Y
, args
.Delta
));
1877 base.WndProc(ref m
);
1881 case Msg
.WM_LBUTTONDOWN
:
1882 case Msg
.WM_MBUTTONDOWN
:
1883 case Msg
.WM_RBUTTONDOWN
: {
1884 if (native_enabled
&& active_tracker
!= null) {
1885 MouseEventArgs args
;
1887 args
= new MouseEventArgs (FromParamToMouseButtons ((int) m
.WParam
.ToInt32()),
1888 mouse_clicks
, LowOrder ((int) m
.LParam
.ToInt32 ()), HighOrder ((int) m
.LParam
.ToInt32 ()), 0);
1889 active_tracker
.OnMouseDown(new MouseEventArgs (args
.Button
, args
.Clicks
, Control
.MousePosition
.X
, Control
.MousePosition
.Y
, args
.Delta
));
1892 base.WndProc(ref m
);
1896 case Msg
.WM_LBUTTONUP
:
1897 case Msg
.WM_MBUTTONUP
:
1898 case Msg
.WM_RBUTTONUP
: {
1899 if (native_enabled
&& active_tracker
!= null) {
1900 MouseEventArgs args
;
1902 args
= new MouseEventArgs (FromParamToMouseButtons ((int) m
.WParam
.ToInt32()),
1903 mouse_clicks
, LowOrder ((int) m
.LParam
.ToInt32 ()), HighOrder ((int) m
.LParam
.ToInt32 ()), 0);
1904 active_tracker
.OnMouseUp(new MouseEventArgs (args
.Button
, args
.Clicks
, Control
.MousePosition
.X
, Control
.MousePosition
.Y
, args
.Delta
));
1908 base.WndProc(ref m
);
1912 case Msg
.WM_GETMINMAXINFO
: {
1915 if (m
.LParam
!= IntPtr
.Zero
) {
1916 mmi
= (MINMAXINFO
)Marshal
.PtrToStructure(m
.LParam
, typeof(MINMAXINFO
));
1918 default_maximized_bounds
= new Rectangle(mmi
.ptMaxPosition
.x
, mmi
.ptMaxPosition
.y
, mmi
.ptMaxSize
.x
, mmi
.ptMaxSize
.y
);
1919 if (maximized_bounds
!= Rectangle
.Empty
) {
1920 mmi
.ptMaxPosition
.x
= maximized_bounds
.Left
;
1921 mmi
.ptMaxPosition
.y
= maximized_bounds
.Top
;
1922 mmi
.ptMaxSize
.x
= maximized_bounds
.Width
;
1923 mmi
.ptMaxSize
.y
= maximized_bounds
.Height
;
1926 if (minimum_size
!= Size
.Empty
) {
1927 mmi
.ptMinTrackSize
.x
= minimum_size
.Width
;
1928 mmi
.ptMinTrackSize
.y
= minimum_size
.Height
;
1931 if (maximum_size
!= Size
.Empty
) {
1932 mmi
.ptMaxTrackSize
.x
= maximum_size
.Width
;
1933 mmi
.ptMaxTrackSize
.y
= maximum_size
.Height
;
1935 Marshal
.StructureToPtr(mmi
, m
.LParam
, false);
1941 base.WndProc (ref m
);
1946 #endregion // Protected Instance Methods
1948 internal void RemoveWindowManager ()
1950 window_manager
= null;
1953 internal override void CheckAcceptButton()
1955 if (accept_button
!= null) {
1956 Button a_button
= accept_button
as Button
;
1958 if (ActiveControl
== a_button
)
1961 if (ActiveControl
is Button
) {
1962 a_button
.paint_as_acceptbutton
= false;
1966 a_button
.paint_as_acceptbutton
= true;
1973 public event EventHandler Activated
;
1974 public event EventHandler Closed
;
1975 public event CancelEventHandler Closing
;
1976 public event EventHandler Deactivate
;
1977 public event InputLanguageChangedEventHandler InputLanguageChanged
;
1978 public event InputLanguageChangingEventHandler InputLanguageChanging
;
1979 public event EventHandler Load
;
1980 public event EventHandler MaximizedBoundsChanged
;
1981 public event EventHandler MaximumSizeChanged
;
1982 public event EventHandler MdiChildActivate
;
1983 public event EventHandler MenuComplete
;
1984 public event EventHandler MenuStart
;
1985 public event EventHandler MinimumSizeChanged
;
1988 [EditorBrowsable(EditorBrowsableState
.Never
)]
1989 public new event EventHandler TabIndexChanged
{
1990 add { base.TabIndexChanged += value; }
1991 remove { base.TabIndexChanged -= value; }
1993 #endregion // Events