* TreeView.cs: Don't draw the selected node when we lose
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / Form.cs
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:
8 // 
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
11 // 
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.
19 //
20 // Copyright (c) 2004-2005 Novell, Inc.
21 //
22 // Authors:
23 //      Peter Bartok    pbartok@novell.com
24 //
25
26 // NOT COMPLETE
27
28 using System;
29 using System.Drawing;
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;
36
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")]
42         [ToolboxItem(false)]
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                    autoscale_base_size;
50                 private static Icon             default_icon;
51                 internal bool                   is_modal;
52                 internal bool                   end_modal;                      // This var is being monitored by the application modal loop
53                 private bool                    control_box;
54                 private bool                    minimize_box;
55                 private bool                    maximize_box;
56                 private bool                    help_button;
57                 private bool                    show_in_taskbar;
58                 private bool                    topmost;
59                 private IButtonControl          accept_button;
60                 private IButtonControl          cancel_button;
61                 private DialogResult            dialog_result;
62                 private FormStartPosition       start_position;
63                 private Form                    owner;
64                 private Form.ControlCollection  owned_forms;
65                 private MdiClient               mdi_container;
66                 private MdiChildContext         mdi_child_context;
67                 private Form                    mdi_parent;
68                 private bool                    key_preview;
69                 private MainMenu                menu;
70                 private Icon                    icon;
71                 private Size                    maximum_size;
72                 private Size                    minimum_size;
73                 private SizeGripStyle           size_grip_style;
74                 private Rectangle               maximized_bounds;
75                 private Rectangle               default_maximized_bounds;
76                 private double                  opacity;
77                 Color                           transparency_key;
78
79                 #endregion      // Local Variables
80
81                 #region Private & Internal Methods
82                 static Form ()
83                 {
84                         default_icon = (Icon)Locale.GetResource("mono.ico");
85                 }
86                 #endregion      // Private & Internal Methods
87
88                 #region Public Classes
89                 public new class ControlCollection : Control.ControlCollection {
90                         Form    form_owner;
91
92                         public ControlCollection(Form owner) : base(owner) {
93                                 this.form_owner = owner;
94                         }
95
96                         public override void Add(Control value) {
97                                 if (Contains (value))
98                                         return;
99                                 AddToList (value);
100                                 ((Form)value).owner=(Form)owner;
101                         }
102
103                         public override void Remove(Control value) {
104                                 ((Form)value).owner = null;
105                                 base.Remove (value);
106                         }
107                 }
108                 #endregion      // Public Classes
109
110                 #region Public Constructor & Destructor
111                 public Form ()
112                 {
113                         SizeF current_scale = GetAutoScaleSize (DeviceContext, Font);
114
115                         autoscale = true;
116                         autoscale_base_size = new Size ((int)current_scale.Width, (int) current_scale.Height);
117                         closing = false;
118                         is_modal = false;
119                         end_modal = false;
120                         dialog_result = DialogResult.None;
121                         start_position = FormStartPosition.WindowsDefaultLocation;
122                         form_border_style = FormBorderStyle.Sizable;
123                         key_preview = false;
124                         opacity = 1D;
125                         menu = null;
126                         icon = default_icon;
127                         minimum_size = new Size(0, 0);
128                         maximum_size = new Size(0, 0);
129                         control_box = true;
130                         minimize_box = true;
131                         maximize_box = true;
132                         help_button = false;
133                         show_in_taskbar = true;
134                         ime_mode = ImeMode.NoControl;
135                         is_visible = false;
136                         is_toplevel = true;
137                         size_grip_style = SizeGripStyle.Auto;
138                         maximized_bounds = Rectangle.Empty;
139                         default_maximized_bounds = Rectangle.Empty;
140                         owned_forms = new Form.ControlCollection(this);
141                         transparency_key = Color.Empty;
142                 }
143                 #endregion      // Public Constructor & Destructor
144
145                 #region Public Static Properties
146
147                 public static Form ActiveForm {
148                         get {
149                                 Control active;
150
151                                 active = FromHandle(XplatUI.GetActive());
152
153                                 if (active != null) {
154                                         if ( !(active is Form)) {
155                                                 Control parent;
156
157                                                 parent = active.Parent;
158                                                 while (parent != null) {
159                                                         if (parent is Form) {
160                                                                 return (Form)parent;
161                                                         }
162                                                         parent = parent.Parent;
163                                                 }
164                                         } else {
165                                                 return (Form)active;
166                                         }
167                                 }
168                                 return null;
169                         }
170                 }
171
172                 #endregion      // Public Static Properties
173
174                 #region Public Instance Properties
175                 [DefaultValue(null)]
176                 public IButtonControl AcceptButton {
177                         get {
178                                 return accept_button;
179                         }
180
181                         set {
182                                 accept_button = value;
183                         }
184                 }
185
186                 [MonoTODO("Figure out a way for transparency support in windows")]
187                 [Browsable(false)]
188                 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
189                 public bool AllowTransparency {
190                         get {
191                                 return false;
192                         }
193
194                         set {
195                         }
196                 }
197
198                 [DefaultValue(true)]
199                 public bool AutoScale {
200                         get {
201                                 return autoscale;
202                         }
203
204                         set {
205                                 autoscale = value;
206                         }
207                 }
208
209                 [Localizable(true)]
210                 [Browsable(false)]
211                 [EditorBrowsable(EditorBrowsableState.Advanced)]
212                 public virtual Size AutoScaleBaseSize {
213                         get {
214                                 return autoscale_base_size;
215                         }
216
217                         set {
218                                 autoscale_base_size = value;
219                         }
220                 }
221
222                 [Localizable(true)]
223                 public override bool AutoScroll {
224                         get {
225                                 return base.AutoScroll;
226                         }
227                         set {
228                                 base.AutoScroll = value;
229                         }
230                 }
231
232                 public override Color BackColor {
233                         get {
234                                 return base.BackColor;
235                         }
236                         set {
237                                 base.BackColor = value;
238                         }
239                 }
240
241                 [DefaultValue(null)]
242                 public IButtonControl CancelButton {
243                         get {
244                                 return cancel_button;
245                         }
246
247                         set {
248                                 cancel_button = value;
249                         }
250                 }
251
252                 [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
253                 [Localizable(true)]
254                 public Size ClientSize {
255                         get {
256                                 return base.ClientSize;
257                         }
258
259                         set {
260                                 base.ClientSize = value;
261                         }
262                 }
263
264                 [DefaultValue(true)]
265                 public bool ControlBox {
266                         get {
267                                 return control_box;
268                         }
269
270                         set {
271                                 if (control_box != value) {
272                                         control_box = value;
273                                         UpdateStyles();
274                                 }
275                         }
276                 }
277
278                 [Browsable(false)]
279                 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
280                 public Rectangle DesktopBounds {
281                         get {
282                                 return new Rectangle(Location, Size);
283                         }
284
285                         set {
286                                 Bounds = value;
287                         }
288                 }
289
290                 [Browsable(false)]
291                 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
292                 public Point DesktopLocation {
293                         get {
294                                 return Location;
295                         }
296
297                         set {
298                                 Location = value;
299                         }
300                 }
301
302                 [Browsable(false)]
303                 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
304                 public DialogResult DialogResult {
305                         get {
306                                 return dialog_result;
307                         }
308
309                         set {
310                                 dialog_result = value;
311
312                                 if (is_modal && (dialog_result != DialogResult.None)) {
313                                         end_modal = true;
314                                 }
315                         }
316                 }
317
318                 [DefaultValue(FormBorderStyle.Sizable)]
319                 [DispId(-504)]
320                 public FormBorderStyle FormBorderStyle {
321                         get {
322                                 return form_border_style;
323                         }
324                         set {
325                                 form_border_style = value;
326                                 if (IsHandleCreated) {
327                                         XplatUI.SetBorderStyle(window.Handle, form_border_style);
328                                 }
329                                 UpdateStyles();
330                         } 
331                 }
332
333                 [DefaultValue(false)]
334                 public bool HelpButton {
335                         get {
336                                 return help_button;
337                         }
338
339                         set {
340                                 if (help_button != value) {
341                                         help_button = value;
342                                         UpdateStyles();
343                                 }
344                         }
345                 }
346
347                 [Localizable(true)]
348                 [AmbientValue(null)]
349                 public Icon Icon {
350                         get {
351                                 return icon;
352                         }
353
354                         set {
355                                 if (icon != value) {
356                                         icon = value;
357
358                                         if (IsHandleCreated) {
359                                                 XplatUI.SetIcon(Handle, icon);
360                                         }
361                                 }
362                         }
363                 }
364
365                 [Browsable(false)]
366                 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
367                 public bool IsMdiChild {
368                         get {
369                                 return mdi_parent != null;
370                         }
371                 }
372
373                 [DefaultValue(false)]
374                 public bool IsMdiContainer {
375                         get {
376                                 return mdi_container != null;
377                         }
378
379                         set {
380                                 if (value && mdi_container == null) {
381                                         mdi_container = new MdiClient();
382                                         Controls.Add(mdi_container);
383                                 } else if (!value && mdi_container != null) {
384                                         Controls.Remove(mdi_container);
385                                         mdi_container.Dispose();
386                                 }
387                         }
388                 }
389
390                 public Form ActiveMdiChild {
391                         get {
392                                 if (!IsMdiContainer)
393                                         return null;
394                                 return (Form) mdi_container.ActiveMdiChild;
395                         }
396                 }
397
398                 [Browsable(false)]
399                 [EditorBrowsable(EditorBrowsableState.Advanced)]
400                 public bool IsRestrictedWindow {
401                         get {
402                                 return false;
403                         }
404                 }
405
406                 [DefaultValue(false)]
407                 public bool KeyPreview {
408                         get {
409                                 return key_preview;
410                         }
411
412                         set {
413                                 key_preview = value;
414                         }
415                 }
416
417                 [DefaultValue(true)]
418                 public bool MaximizeBox {
419                         get {
420                                 return maximize_box;
421                         }
422                         set {
423                                 if (maximize_box != value) {
424                                         maximize_box = value;
425                                         UpdateStyles();
426                                 }
427                         }
428                 }
429
430                 [DefaultValue("{Width=0, Height=0}")]
431                 [Localizable(true)]
432                 [RefreshProperties(RefreshProperties.Repaint)]
433                 public Size MaximumSize {
434                         get {
435                                 return maximum_size;
436                         }
437
438                         set {
439                                 if (maximum_size != value) {
440                                         maximum_size = value;
441                                         OnMaximumSizeChanged(EventArgs.Empty);
442                                 }
443                         }
444                 }
445
446                 [Browsable(false)]
447                 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
448                 public Form[] MdiChildren {
449                         get {
450                                 if (mdi_container != null) {
451                                         Form[] form_list;
452
453                                         form_list = new Form[mdi_container.Controls.Count];
454                                         for (int i = 0; i < mdi_container.Controls.Count; i++) {
455                                                 form_list[i] = (Form)mdi_container.Controls[i];
456                                         }
457                                         return form_list;
458                                 } else {
459                                         return new Form[0];
460                                 }
461                         }
462                 }
463
464                 [MonoTODO("Finish setter")]
465                 [Browsable(false)]
466                 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
467                 public Form MdiParent {
468                         get {
469                                 return mdi_parent;
470                         }
471
472                         set {
473                                 SuspendLayout ();
474
475                                 // TopLevel = true;
476
477                                 if (!value.IsMdiContainer)
478                                         throw new ArgumentException ();
479
480                                 if (mdi_parent != null) {
481                                         mdi_parent.MdiContainer.Controls.Remove (this);
482                                 }
483
484                                 mdi_parent = value;
485                                 if (mdi_parent != null) {
486                                         mdi_child_context = new MdiChildContext (this,
487                                                         mdi_parent.MdiContainer);
488                                         mdi_parent.MdiContainer.Controls.Add (this);
489                                 }
490
491                                 ResumeLayout ();
492                         }
493                 }
494
495                 internal MdiClient MdiContainer {
496                         get { return mdi_container; }
497                 }
498
499                 [DefaultValue(null)]
500                 public MainMenu Menu {
501                         get {
502                                 return menu;
503                         }
504
505                         set {
506                                 if (menu != value) {
507                                         menu = value;
508
509                                         if (menu != null) {
510                                                 menu.SetForm (this);
511                                                 MenuAPI.SetMenuBarWindow (menu.Handle, this);
512
513                                                 if (IsHandleCreated) {
514                                                         XplatUI.SetMenu (window.Handle, menu.Handle);
515                                                 }
516
517                                                 UpdateBounds (bounds.X, bounds.Y, bounds.Width, bounds.Height, ClientSize.Width, ClientSize.Height - 
518                                                         ThemeEngine.Current.CalcMenuBarSize (DeviceContext, menu.Handle, ClientSize.Width));
519                                         } else
520                                                 UpdateBounds ();
521                                 }
522                         }
523                 }
524
525                 [DefaultValue(true)]
526                 public bool MinimizeBox {
527                         get {
528                                 return minimize_box;
529                         }
530                         set {
531                                 if (minimize_box != value) {
532                                         minimize_box = value;
533                                         UpdateStyles();
534                                 }
535                         }
536                 }
537
538                 [DefaultValue("{Width=0, Height=0}")]
539                 [Localizable(true)]
540                 [RefreshProperties(RefreshProperties.Repaint)]
541                 public Size MinimumSize {
542                         get {
543                                 return minimum_size;
544                         }
545
546                         set {
547                                 if (minimum_size != value) {
548                                         minimum_size = value;
549                                         OnMinimumSizeChanged(EventArgs.Empty);
550                                 }
551                         }
552                 }
553
554                 [Browsable(false)]
555                 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
556                 public bool Modal  {
557                         get {
558                                 return is_modal;
559                         }
560                 }
561
562                 [MonoTODO("Investigate ways to implement opacity")]
563                 [DefaultValue(1D)]
564                 [TypeConverter(typeof(OpacityConverter))]
565                 public double Opacity {
566                         get {
567                                 return opacity;
568                         }
569
570                         set {
571                                 opacity = value;
572                         }
573                 }
574                         
575
576                 [Browsable(false)]
577                 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
578                 public Form[] OwnedForms {
579                         get {
580                                 Form[] form_list;
581
582                                 form_list = new Form[owned_forms.Count];
583
584                                 for (int i=0; i<owned_forms.Count; i++) {
585                                         form_list[i] = (Form)owned_forms[i];
586                                 }
587
588                                 return form_list;
589                         }
590                 }
591
592                 [Browsable(false)]
593                 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
594                 public Form Owner {
595                         get {
596                                 return owner;
597                         }
598
599                         set {
600                                 if (owner != value) {
601                                         if (owner != null) {
602                                                 owner.RemoveOwnedForm(this);
603                                         }
604                                         owner = value;
605                                         owner.AddOwnedForm(this);
606                                         if (owner != null) {
607                                                 XplatUI.SetTopmost(this.window.Handle, owner.window.Handle, true);
608                                         } else {
609                                                 XplatUI.SetTopmost(this.window.Handle, IntPtr.Zero, false);
610                                         }
611                                 }
612                         }
613                 }
614
615                 [DefaultValue(true)]
616                 public bool ShowInTaskbar {
617                         get {
618                                 return show_in_taskbar;
619                         }
620                         set {
621                                 if (show_in_taskbar != value) {
622                                         show_in_taskbar = value;
623                                         UpdateStyles();
624                                 }
625                         }
626                 }
627
628                 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
629                 [Localizable(false)]
630                 public Size Size {
631                         get {
632                                 return base.Size;
633                         }
634
635                         set {
636                                 base.Size = value;
637                         }
638                 }
639
640                 [MonoTODO("Trigger something when GripStyle is set")]
641                 [DefaultValue(SizeGripStyle.Auto)]
642                 public SizeGripStyle SizeGripStyle {
643                         get {
644                                 return size_grip_style;
645                         }
646
647                         set {
648                                 size_grip_style = value;
649                         }
650                 }
651
652                 [DefaultValue(FormStartPosition.WindowsDefaultLocation)]
653                 [Localizable(true)]
654                 public FormStartPosition StartPosition {
655                         get {
656                                 return start_position;
657                         }
658
659                         set {
660                                 if (start_position == FormStartPosition.WindowsDefaultLocation) {               // Only do this if it's not set yet
661                                         start_position = value;
662                                         if (IsHandleCreated) {
663                                                 switch(start_position) {
664                                                         case FormStartPosition.CenterParent: {
665                                                                 CenterToParent();
666                                                                 break;
667                                                         }
668
669                                                         case FormStartPosition.CenterScreen: {
670                                                                 CenterToScreen();
671                                                                 break;
672                                                         }
673
674                                                         default: {
675                                                                 break;
676                                                         }
677                                                 }
678                                         }
679                                 }
680                         }
681                 }
682
683                 [Browsable(false)]
684                 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
685                 [EditorBrowsable(EditorBrowsableState.Never)]
686                 public int TabIndex {
687                         get {
688                                 return base.TabIndex;
689                         }
690
691                         set {
692                                 base.TabIndex = value;
693                         }
694                 }
695
696                 [Browsable(false)]
697                 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
698                 [EditorBrowsable(EditorBrowsableState.Advanced)]
699                 public bool TopLevel {
700                         get {
701                                 return GetTopLevel();
702                         }
703
704                         set {
705                                 if (!value && IsMdiContainer)
706                                         throw new ArgumentException ("MDI Container forms must be top level.");
707                                 SetTopLevel(value);
708                         }
709                 }
710
711                 [DefaultValue(false)]
712                 public bool TopMost {
713                         get {
714                                 return topmost;
715                         }
716
717                         set {
718                                 if (topmost != value) {
719                                         topmost = value;
720                                         XplatUI.SetTopmost(window.Handle, owner != null ? owner.window.Handle : IntPtr.Zero, value);
721                                 }
722                         }
723                 }
724
725                 public Color TransparencyKey {
726                         get {
727                                 return transparency_key;
728                         }
729
730                         set {
731                                 AllowTransparency = true;
732                                 transparency_key = value;
733                                 // TODO: change window attributes; a new driver call
734                         }
735                 }
736
737                 [DefaultValue(FormWindowState.Normal)]
738                 public FormWindowState WindowState {
739                         get {
740                                 return XplatUI.GetWindowState(Handle);
741                         }
742
743                         set {
744                                 XplatUI.SetWindowState(Handle, value);
745                         }
746                 }
747
748                 #endregion      // Public Instance Properties
749
750                 #region Protected Instance Properties
751                 [MonoTODO("Need to set start position properly")]
752                 protected override CreateParams CreateParams {
753                         get {
754                                 CreateParams cp = new CreateParams ();
755
756                                 cp.Caption = Text;
757                                 cp.ClassName = XplatUI.DefaultClassName;
758                                 cp.ClassStyle = 0;
759                                 cp.ExStyle = 0;
760                                 cp.Param = 0;
761                                 cp.Parent = IntPtr.Zero;
762
763 //                              if (start_position == FormStartPosition.WindowsDefaultLocation) {
764                                         cp.X = unchecked((int)0x80000000);
765                                         cp.Y = unchecked((int)0x80000000);
766 //                              } else {
767 //                                      cp.X = Left;
768 //                                      cp.Y = Top;
769 //                              }
770                                 cp.Width = Width;
771                                 cp.Height = Height;
772
773                                 cp.Style |= (int)WindowStyles.WS_CLIPCHILDREN | (int)WindowStyles.WS_CLIPSIBLINGS;
774
775                                 if (IsMdiChild) {
776                                         cp.Style |= (int)WindowStyles.WS_CHILD;
777                                         cp.Parent = Parent.Handle;
778                                 }
779
780                                 if (!IsMdiChild) {
781                                         switch (FormBorderStyle) {
782
783                                         case FormBorderStyle.Fixed3D: {
784                                                 cp.Style |= (int)WindowStyles.WS_CAPTION;
785                                                 cp.ExStyle |= (int)WindowStyles.WS_EX_OVERLAPPEDWINDOW;
786                                                 break;
787                                         }
788
789                                         case FormBorderStyle.FixedDialog: {
790                                                 cp.Style |= (int)WindowStyles.WS_CAPTION;
791                                                 cp.ExStyle |= (int)(WindowStyles.WS_EX_DLGMODALFRAME | WindowStyles.WS_EX_WINDOWEDGE);
792                                                 break;
793                                         }
794
795                                         case FormBorderStyle.FixedSingle: {
796                                                 cp.Style |= (int)WindowStyles.WS_CAPTION;
797                                                 cp.ExStyle |= (int)(WindowStyles.WS_EX_WINDOWEDGE);
798                                                 break;
799                                         }
800
801                                         case FormBorderStyle.FixedToolWindow: {
802                                                 cp.Style |= (int)WindowStyles.WS_CAPTION;
803                                                 cp.ExStyle |= (int)(WindowStyles.WS_EX_WINDOWEDGE | WindowStyles.WS_EX_TOOLWINDOW);
804                                                 break;
805                                         }
806
807                                         case FormBorderStyle.Sizable: {
808                                                 cp.Style |= (int)WindowStyles.WS_OVERLAPPEDWINDOW;
809                                                 cp.ExStyle |= (int)(WindowStyles.WS_EX_WINDOWEDGE);
810                                                 break;
811                                         }
812
813                                         case FormBorderStyle.SizableToolWindow: {
814                                                 cp.Style |= (int)WindowStyles.WS_OVERLAPPEDWINDOW;
815                                                 cp.ExStyle |= (int)(WindowStyles.WS_EX_WINDOWEDGE | WindowStyles.WS_EX_TOOLWINDOW);
816                                                 break;
817                                         }
818                                         }
819                                 }
820
821                                 if (ShowInTaskbar) {
822                                         cp.ExStyle |= (int)WindowStyles.WS_EX_APPWINDOW;
823                                 }
824
825                                 if (MaximizeBox) {
826                                         cp.Style |= (int)WindowStyles.WS_MAXIMIZEBOX;
827                                 }
828
829                                 if (MinimizeBox) {
830                                         cp.Style |= (int)WindowStyles.WS_MINIMIZEBOX;
831                                 }
832
833                                 if (ControlBox) {
834                                         cp.Style |= (int)WindowStyles.WS_SYSMENU;
835                                 }
836
837                                 if (HelpButton) {
838                                         cp.ExStyle |= (int)WindowStyles.WS_EX_CONTEXTHELP;
839                                 }
840
841                                 return cp;
842                         }
843                 }
844
845                 protected override ImeMode DefaultImeMode {
846                         get {
847                                 return ImeMode.NoControl;
848                         }
849                 }
850
851                 protected override Size DefaultSize {
852                         get {
853                                 return new Size (250, 250);
854                         }
855                 }
856
857                 protected Rectangle MaximizedBounds {
858                         get {
859                                 if (maximized_bounds != Rectangle.Empty) {
860                                         return maximized_bounds;
861                                 }
862                                 return default_maximized_bounds;
863                         }
864
865                         set {
866                                 maximized_bounds = value;
867                                 OnMaximizedBoundsChanged(EventArgs.Empty);
868                         }
869                 }
870                 #endregion      // Protected Instance Properties
871
872                 #region Public Static Methods
873                 [EditorBrowsable(EditorBrowsableState.Advanced)]
874                 public static SizeF GetAutoScaleSize (Font font)
875                 {
876                         return XplatUI.GetAutoScaleSize(font);
877                 }
878
879                 #endregion      // Public Static Methods
880
881                 #region Public Instance Methods
882                 internal SizeF GetAutoScaleSize (Graphics g, Font font)
883                 {
884                         //
885                         // The following constants come from the dotnet mailing list
886                         // discussion: http://discuss.develop.com/archives/wa.exe?A2=ind0203A&L=DOTNET&P=R3655
887                         //
888                         // The magic number is "Its almost the length
889                         // of the string with a smattering added in
890                         // for compat with earlier code".
891                         //
892         
893                         string magic_string = "The quick brown fox jumped over the lazy dog.";
894                         double magic_number = 44.549996948242189;
895                         float width = (float) (g.MeasureString (magic_string, font).Width / magic_number);
896                         
897                         return new SizeF (width, font.Height);
898                 }
899                                                  
900                 public void Activate() {
901                         Form    active;
902
903                         // The docs say activate only activates if our app is already active
904                         active = ActiveForm;
905                         if ((active != null) && (this != active)) {
906                                 XplatUI.Activate(window.Handle);
907                         }
908                 }
909
910                 public void AddOwnedForm(Form ownedForm) {
911                         owned_forms.Add(ownedForm);
912                 }
913
914                 public void Close () {
915                         CancelEventArgs args = new CancelEventArgs ();
916                         OnClosing (args);
917                         if (!args.Cancel) {
918                                 OnClosed (EventArgs.Empty);
919                                 closing = true;
920                                 return;
921                         }
922                 }
923
924                 public void LayoutMdi(MdiLayout value) {
925                         if (mdi_container != null) {
926                                 mdi_container.LayoutMdi(value);
927                         }
928                 }
929
930                 public void RemoveOwnedForm(Form ownedForm) {
931                         owned_forms.Remove(ownedForm);
932                 }
933
934                 public void SetDesktopBounds(int x, int y, int width, int height) {
935                         DesktopBounds = new Rectangle(x, y, width, height);
936                 }
937
938                 public void SetDesktopLocation(int x, int y) {
939                         DesktopLocation = new Point(x, y);
940                 }
941
942                 public DialogResult ShowDialog() {
943                         return ShowDialog(null);
944                 }
945
946                 public DialogResult ShowDialog(IWin32Window ownerWin32) {
947                         Form            previous;
948
949                         if (ownerWin32 != null) {
950                                 this.owner = (Form)Control.FromHandle(ownerWin32.Handle);
951                         }
952
953                         if (is_modal) {
954                                 return DialogResult.None;
955                         }
956
957                         if (Visible) {
958                                 throw new InvalidOperationException("Already visible forms cannot be displayed as a modal dialog. Set the Visible property to 'false' prior to calling Form.ShowDialog.");
959                         }
960
961                         #if broken
962                         // Can't do this, will screw us in the modal loop
963                         form_parent_window.Parent = this.owner;
964                         #endif
965
966                         previous = Form.ActiveForm;
967
968                         if (!IsHandleCreated) {
969                                 CreateControl();
970                         }
971
972                         XplatUI.SetModal(window.Handle, true);
973
974                         Show();
975                         PerformLayout();
976
977                         is_modal = true;
978                         Application.ModalRun(this);
979                         is_modal = false;
980                         Hide();
981
982                         XplatUI.SetModal(window.Handle, false);
983
984                         if (previous != null) {
985                                 // Cannot use Activate(), it has a check for the current active window...
986                                 XplatUI.Activate(previous.window.Handle);
987                         }
988
989                         return DialogResult;
990                 }
991
992                 public override string ToString() {
993                         return GetType().FullName.ToString() + ", Text: " + Text;
994                 }
995                 #endregion      // Public Instance Methods
996
997                 #region Protected Instance Methods
998                 [MonoTODO("Finish when MDI is more complete")]
999                 protected void ActivateMdiChild(Form form) {
1000                         OnMdiChildActivate(EventArgs.Empty);
1001                         throw new NotImplementedException();
1002                 }
1003
1004                 [EditorBrowsable(EditorBrowsableState.Advanced)]
1005                 protected override void AdjustFormScrollbars(bool displayScrollbars) {
1006                         base.AdjustFormScrollbars (displayScrollbars);
1007                 }
1008
1009                 [EditorBrowsable(EditorBrowsableState.Advanced)]
1010                 protected void ApplyAutoScaling()
1011                 {
1012                         SizeF current_size_f = GetAutoScaleSize (DeviceContext, Font);
1013                         Size current_size = new Size ((int) current_size_f.Width, (int) current_size_f.Height);
1014
1015                         if (current_size == autoscale_base_size)
1016                                 return;
1017
1018                         //
1019                         // I tried applying the Fudge height factor from:
1020                         // http://blogs.msdn.com/mharsh/archive/2004/01/25/62621.aspx
1021                         // but it makes things larger without looking better.
1022                         //
1023                         Scale (current_size_f.Width / AutoScaleBaseSize.Width,
1024                                current_size_f.Height / AutoScaleBaseSize.Height);
1025                         
1026                         AutoScaleBaseSize = current_size;
1027                 }
1028
1029                 protected void CenterToParent() {
1030                         Control ctl;
1031                         int     w;
1032                         int     h;
1033
1034                         if (Width > 0) {
1035                                 w = Width;
1036                         } else {
1037                                 w = DefaultSize.Width;
1038                         }
1039
1040                         if (Height > 0) {
1041                                 h = Height;
1042                         } else {
1043                                 h = DefaultSize.Height;
1044                         }
1045
1046                         ctl = null;
1047                         if (parent != null) {
1048                                 ctl = parent;
1049                         } else if (owner != null) {
1050                                 ctl = owner;
1051                         }
1052
1053                         if (owner != null) {
1054                                 this.Location = new Point(ctl.Left + ctl.Width / 2 - w /2, ctl.Top + ctl.Height / 2 - h / 2);
1055                         }
1056                 }
1057
1058                 protected void CenterToScreen() {
1059                         Size    DisplaySize;
1060                         int     w;
1061                         int     h;
1062
1063                         if (Width > 0) {
1064                                 w = Width;
1065                         } else {
1066                                 w = DefaultSize.Width;
1067                         }
1068
1069                         if (Height > 0) {
1070                                 h = Height;
1071                         } else {
1072                                 h = DefaultSize.Height;
1073                         }
1074
1075                         XplatUI.GetDisplaySize(out DisplaySize);
1076                         this.Location = new Point(DisplaySize.Width / 2 - w / 2, DisplaySize.Height / 2 - h / 2);
1077                 }
1078
1079                 [EditorBrowsable(EditorBrowsableState.Advanced)]
1080                 protected override Control.ControlCollection CreateControlsInstance() {
1081                         return base.CreateControlsInstance ();
1082                 }
1083
1084                 [EditorBrowsable(EditorBrowsableState.Advanced)]
1085                 protected override void CreateHandle() {
1086                         base.CreateHandle ();
1087                         if (icon != null) {
1088                                 XplatUI.SetIcon(window.Handle, icon);
1089                         }
1090                 }
1091
1092                 [EditorBrowsable(EditorBrowsableState.Advanced)]
1093                 protected override void DefWndProc(ref Message m) {
1094                         base.DefWndProc (ref m);
1095                 }
1096
1097                 protected override void Dispose(bool disposing) {
1098                         base.Dispose (disposing);
1099                 }
1100
1101                 [EditorBrowsable(EditorBrowsableState.Advanced)]
1102                 protected virtual void OnActivated(EventArgs e) {
1103                         if (Activated != null) {
1104                                 Activated(this, e);
1105                         }
1106                 }
1107
1108                 [EditorBrowsable(EditorBrowsableState.Advanced)]
1109                 protected virtual void OnClosed(EventArgs e) {
1110                         if (Closed != null) {
1111                                 Closed(this, e);
1112                         }
1113                 }
1114
1115                 [EditorBrowsable(EditorBrowsableState.Advanced)]
1116                 protected virtual void OnClosing(System.ComponentModel.CancelEventArgs e) {
1117                         if (Closing != null) {
1118                                 Closing(this, e);
1119                         }
1120                 }
1121
1122                 [EditorBrowsable(EditorBrowsableState.Advanced)]
1123                 protected override void OnCreateControl() {
1124                         base.OnCreateControl ();
1125                         if (this.ActiveControl == null) {
1126                                 bool visible;
1127
1128                                 // This visible hack is to work around CanSelect always being false if one of the parents
1129                                 // is not visible; and we by default create Form invisible...
1130                                 visible = this.is_visible;
1131                                 this.is_visible = true;
1132
1133                                 if (SelectNextControl(this, true, true, true, true) == false) {
1134                                         Select(this);
1135                                 }
1136
1137                                 this.is_visible = visible;
1138                         }
1139
1140                         if (!IsMdiChild) {
1141                                 switch (StartPosition) {
1142                                 case FormStartPosition.CenterScreen:
1143                                         this.CenterToScreen();
1144                                         break;
1145                                 case FormStartPosition.CenterParent:
1146                                         this.CenterToParent ();
1147                                         break;
1148                                 }
1149                         } else {
1150                                 Left = 25 * MdiParent.MdiContainer.ChildrenCreated + 1;
1151                                 Top = 25 * MdiParent.MdiContainer.ChildrenCreated + 1;
1152                                 MdiParent.MdiContainer.ChildrenCreated++;
1153                         }
1154
1155                         if (menu != null) {
1156                                 XplatUI.SetMenu(window.Handle, menu.Handle);
1157                         }
1158
1159                         OnLoad(EventArgs.Empty);
1160
1161                         // Send initial location
1162                         OnLocationChanged(EventArgs.Empty);
1163                 }
1164
1165                 [EditorBrowsable(EditorBrowsableState.Advanced)]
1166                 protected virtual void OnDeactivate(EventArgs e) {
1167                         if (Deactivate != null) {
1168                                 Deactivate(this, e);
1169                         }
1170                 }
1171
1172                 [EditorBrowsable(EditorBrowsableState.Advanced)]
1173                 protected override void OnFontChanged(EventArgs e) {
1174                         base.OnFontChanged (e);
1175                 }
1176
1177                 [EditorBrowsable(EditorBrowsableState.Advanced)]
1178                 protected override void OnHandleCreated(EventArgs e) {
1179                         XplatUI.SetBorderStyle(window.Handle, form_border_style);
1180                         base.OnHandleCreated (e);
1181                 }
1182
1183                 [EditorBrowsable(EditorBrowsableState.Advanced)]
1184                 protected override void OnHandleDestroyed(EventArgs e) {
1185                         base.OnHandleDestroyed (e);
1186                 }
1187
1188                 [EditorBrowsable(EditorBrowsableState.Advanced)]
1189                 protected virtual void OnInputLanguageChanged(InputLanguageChangedEventArgs e) {
1190                         if (InputLanguageChanged!=null) {
1191                                 InputLanguageChanged(this, e);
1192                         }
1193                 }
1194
1195                 [EditorBrowsable(EditorBrowsableState.Advanced)]
1196                 protected virtual void OnInputLanguageChanging(InputLanguageChangingEventArgs e) {
1197                         if (InputLanguageChanging!=null) {
1198                                 InputLanguageChanging(this, e);
1199                         }
1200                 }
1201
1202                 [EditorBrowsable(EditorBrowsableState.Advanced)]
1203                 protected virtual void OnLoad(EventArgs e) {
1204                         if (Load != null) {
1205                                 Load(this, e);
1206                         }
1207                         if (AutoScale){
1208                                 ApplyAutoScaling ();
1209                                 AutoScale = false;
1210                         }
1211                 }
1212
1213                 [EditorBrowsable(EditorBrowsableState.Advanced)]
1214                 protected virtual void OnMaximizedBoundsChanged(EventArgs e) {
1215                         if (MaximizedBoundsChanged != null) {
1216                                 MaximizedBoundsChanged(this, e);
1217                         }
1218                 }
1219
1220                 [EditorBrowsable(EditorBrowsableState.Advanced)]
1221                 protected virtual void OnMaximumSizeChanged(EventArgs e) {
1222                         if (MaximumSizeChanged != null) {
1223                                 MaximumSizeChanged(this, e);
1224                         }
1225                 }
1226
1227                 [EditorBrowsable(EditorBrowsableState.Advanced)]
1228                 protected virtual void OnMdiChildActivate(EventArgs e) {
1229                         if (MdiChildActivate != null) {
1230                                 MdiChildActivate(this, e);
1231                         }
1232                 }
1233
1234                 [EditorBrowsable(EditorBrowsableState.Advanced)]
1235                 protected virtual void OnMenuComplete(EventArgs e) {
1236                         if (MenuComplete != null) {
1237                                 MenuComplete(this, e);
1238                         }
1239                 }
1240
1241                 [EditorBrowsable(EditorBrowsableState.Advanced)]
1242                 protected virtual void OnMenuStart(EventArgs e) {
1243                         if (MenuStart != null) {
1244                                 MenuStart(this, e);
1245                         }
1246                 }
1247
1248                 [EditorBrowsable(EditorBrowsableState.Advanced)]
1249                 protected virtual void OnMinimumSizeChanged(EventArgs e) {
1250                         if (MinimumSizeChanged != null) {
1251                                 MinimumSizeChanged(this, e);
1252                         }
1253                 }
1254
1255                 [EditorBrowsable(EditorBrowsableState.Advanced)]
1256                 protected override void OnPaint (PaintEventArgs pevent) {
1257                         base.OnPaint (pevent);
1258                 }
1259
1260                 [EditorBrowsable(EditorBrowsableState.Advanced)]
1261                 protected override void OnResize(EventArgs e) {
1262                         base.OnResize(e);
1263                 }
1264
1265                 [EditorBrowsable(EditorBrowsableState.Advanced)]
1266                 protected override void OnStyleChanged(EventArgs e) {
1267                         base.OnStyleChanged (e);
1268                 }
1269
1270                 [EditorBrowsable(EditorBrowsableState.Advanced)]
1271                 protected override void OnTextChanged(EventArgs e) {
1272                         base.OnTextChanged (e);
1273                 }
1274
1275                 [EditorBrowsable(EditorBrowsableState.Advanced)]
1276                 protected override void OnVisibleChanged(EventArgs e) {
1277                         base.OnVisibleChanged (e);
1278                 }
1279
1280                 protected override bool ProcessCmdKey(ref Message msg, Keys keyData) {
1281                         if (base.ProcessCmdKey (ref msg, keyData)) {
1282                                 return true;
1283                         }
1284
1285                         // Give our menu a shot
1286                         if (menu != null) {
1287                                 return menu.ProcessCmdKey(ref msg, keyData);
1288                         }
1289
1290                         return false;
1291                 }
1292
1293                 // LAMESPEC - Not documented that Form overrides ProcessDialogChar; class-status showed
1294                 [EditorBrowsable (EditorBrowsableState.Advanced)]
1295                 protected override bool ProcessDialogChar(char charCode) {
1296                         return base.ProcessDialogChar (charCode);
1297                 }
1298
1299                 protected override bool ProcessDialogKey(Keys keyData) {
1300                         if ((keyData & Keys.Modifiers) == 0) {
1301                                 if (keyData == Keys.Enter && accept_button != null) {
1302                                         accept_button.PerformClick();
1303                                         return true;
1304                                 } else if (keyData == Keys.Escape && cancel_button != null) {
1305                                         cancel_button.PerformClick();
1306                                         return true;
1307                                 }
1308                         }
1309                         return base.ProcessDialogKey(keyData);
1310                 }
1311
1312                 protected override bool ProcessKeyPreview(ref Message msg) {
1313                         if (key_preview) {
1314                                 if (ProcessKeyEventArgs(ref msg)) {
1315                                         return true;
1316                                 }
1317                         }
1318                         return base.ProcessKeyPreview (ref msg);
1319                 }
1320
1321                 protected override bool ProcessTabKey(bool forward) {
1322                         return SelectNextControl(ActiveControl, forward, true, true, true);
1323                 }
1324
1325                 [EditorBrowsable(EditorBrowsableState.Advanced)]
1326                 protected override void ScaleCore(float dx, float dy) {
1327                         base.ScaleCore (dx, dy);
1328                 }
1329
1330                 protected override void Select(bool directed, bool forward) {
1331                         Form    parent;
1332
1333                         if (directed) {
1334                                 base.SelectNextControl(null, forward, true, true, true);
1335                         }
1336
1337                         parent = this.ParentForm;
1338                         if (parent != null) {
1339                                 parent.ActiveControl = this;
1340                         }
1341
1342                         Activate();
1343                 }
1344
1345                 [EditorBrowsable(EditorBrowsableState.Advanced)]
1346                 protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified) {
1347                         base.SetBoundsCore (x, y, width, height, specified);
1348                 }
1349
1350                 [EditorBrowsable(EditorBrowsableState.Advanced)]
1351                 protected override void SetClientSizeCore(int x, int y) {
1352                         if ((minimum_size.Width != 0) && (x < minimum_size.Width)) {
1353                                 x = minimum_size.Width;
1354                         } else if ((maximum_size.Width != 0) && (x > maximum_size.Width)) {
1355                                 x = maximum_size.Width;
1356                         }
1357
1358                         if ((minimum_size.Height != 0) && (y < minimum_size.Height)) {
1359                                 y = minimum_size.Height;
1360                         } else if ((maximum_size.Height != 0) && (y > maximum_size.Height)) {
1361                                 y = maximum_size.Height;
1362                         }
1363
1364                         Rectangle ClientRect = new Rectangle(0, 0, x, y);
1365                         Rectangle WindowRect;
1366                         CreateParams cp = this.CreateParams;
1367
1368                         IntPtr menu_handle = (menu == null)?IntPtr.Zero:menu.Handle;
1369
1370                         if (XplatUI.CalculateWindowRect(Handle, ref ClientRect, cp.Style, cp.ExStyle, menu_handle, out WindowRect) )
1371                                 SetBoundsCore(bounds.X, bounds.Y, WindowRect.Width, WindowRect.Height, BoundsSpecified.Size);
1372                 }
1373
1374                 [EditorBrowsable(EditorBrowsableState.Advanced)]
1375                 protected override void SetVisibleCore(bool value) {
1376                         base.SetVisibleCore (value);
1377                 }
1378
1379                 protected override void UpdateDefaultButton() {
1380                         base.UpdateDefaultButton ();
1381                 }
1382
1383                 [EditorBrowsable(EditorBrowsableState.Advanced)]
1384                 protected override void WndProc(ref Message m) {
1385
1386                         if (IsMdiChild && mdi_child_context != null &&
1387                                         mdi_child_context.HandleMessage (ref m)) {
1388                                 return;
1389                         }
1390
1391                         switch((Msg)m.Msg) {
1392                                 case Msg.WM_CLOSE: {
1393                                         CancelEventArgs args = new CancelEventArgs();
1394
1395                                         OnClosing(args);
1396
1397                                         if (!args.Cancel) {
1398                                                 OnClosed(EventArgs.Empty);
1399                                                 closing = true;
1400                                                 base.WndProc(ref m);
1401                                                 break;
1402                                         }
1403                                         break;
1404                                 }
1405
1406                                 case Msg.WM_ACTIVATE: {
1407                                         if (m.WParam != (IntPtr)WindowActiveFlags.WA_INACTIVE) {
1408                                                 OnActivated(EventArgs.Empty);
1409                                         } else {
1410                                                 OnDeactivate(EventArgs.Empty);
1411                                         }
1412                                         return;
1413                                 }
1414
1415                                 case Msg.WM_KILLFOCUS: {
1416                                         base.WndProc(ref m);
1417                                         return;
1418                                 }
1419
1420                                 case Msg.WM_SETFOCUS: {
1421                                         if (ActiveControl != null && ActiveControl != this) {
1422                                                 ActiveControl.Focus();
1423                                                 return; // FIXME - do we need to run base.WndProc, even though we just changed focus?
1424                                         }
1425                                         base.WndProc(ref m);
1426                                         return;
1427                                 }
1428
1429                                 // Menu drawing
1430                                 case Msg.WM_NCLBUTTONDOWN: {
1431                                         if (this.menu != null) {
1432                                                 int x = LowOrder ((int) m.LParam.ToInt32 ()) ;
1433                                                 int y = HighOrder ((int) m.LParam.ToInt32 ());
1434                                                 menu.OnMouseDown(this, new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()), mouse_clicks, x, y, 0));
1435                                         }
1436                                         base.WndProc(ref m);
1437                                         return;
1438                                 }
1439
1440                                 case Msg.WM_NCMOUSEMOVE: {
1441                                         if (this.menu != null) {
1442                                                 menu.OnMouseMove(this, new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()), 
1443                                                         mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()), 0));
1444                                         }
1445                                         base.WndProc(ref m);
1446                                         return;
1447                                 }
1448
1449                                 case Msg.WM_NCPAINT: {
1450                                         if (this.menu != null) {
1451                                                 Point pnt = XplatUI.GetMenuOrigin(window.Handle);
1452                                                 MenuAPI.DrawMenuBar (menu.Handle, new Rectangle (pnt.X, pnt.Y, ClientSize.Width, 0));
1453                                         }
1454
1455                                         base.WndProc(ref m);
1456                                         return;
1457                                 }
1458
1459                                 // This message is only received under Win32
1460                                 case Msg.WM_NCCALCSIZE: {
1461                                         XplatUIWin32.NCCALCSIZE_PARAMS  ncp;
1462
1463                                         if ((menu != null) && (m.WParam == (IntPtr)1)) {
1464                                                 ncp = (XplatUIWin32.NCCALCSIZE_PARAMS)Marshal.PtrToStructure(m.LParam, typeof(XplatUIWin32.NCCALCSIZE_PARAMS));
1465
1466                                                 // Adjust for menu
1467                                                 ncp.rgrc1.top += ThemeEngine.Current.CalcMenuBarSize (DeviceContext, menu.menu_handle, ClientSize.Width);
1468                                                 Marshal.StructureToPtr(ncp, m.LParam, true);
1469                                         }
1470                                         DefWndProc(ref m);
1471                                         break;
1472                                 }
1473
1474                                 case Msg.WM_GETMINMAXINFO: {
1475                                         XplatUIWin32.MINMAXINFO mmi;
1476
1477                                         if (m.LParam != IntPtr.Zero) {
1478                                                 mmi = (XplatUIWin32.MINMAXINFO)Marshal.PtrToStructure(m.LParam, typeof(XplatUIWin32.MINMAXINFO));
1479                                                 default_maximized_bounds = new Rectangle(mmi.ptMaxPosition.x, mmi.ptMaxPosition.y, mmi.ptMaxSize.x, mmi.ptMaxSize.y);
1480                                                 if (maximized_bounds != Rectangle.Empty) {
1481                                                         mmi.ptMaxSize.x = maximized_bounds.Width;
1482                                                         mmi.ptMaxSize.y = maximized_bounds.Height;
1483                                                 }
1484
1485                                                 Marshal.StructureToPtr(mmi, m.LParam, false);
1486                                         }
1487                                         break;
1488                                 }
1489
1490                                 default: {
1491                                         base.WndProc (ref m);
1492                                         break;
1493                                 }
1494                         }
1495                 }
1496                 #endregion      // Protected Instance Methods
1497
1498                 #region Events
1499                 public event EventHandler Activated;
1500                 public event EventHandler Closed;
1501                 public event CancelEventHandler Closing;
1502                 public event EventHandler Deactivate;
1503                 public event InputLanguageChangedEventHandler InputLanguageChanged;
1504                 public event InputLanguageChangingEventHandler InputLanguageChanging;
1505                 public event EventHandler Load;
1506                 public event EventHandler MaximizedBoundsChanged;
1507                 public event EventHandler MaximumSizeChanged;
1508                 public event EventHandler MdiChildActivate;
1509                 public event EventHandler MenuComplete;
1510                 public event EventHandler MenuStart;
1511                 public event EventHandler MinimumSizeChanged;
1512
1513                 [Browsable(false)]
1514                 [EditorBrowsable(EditorBrowsableState.Never)]
1515                 public new event EventHandler TabIndexChanged;
1516                 #endregion      // Events
1517         }
1518 }