8a4c36c9b78620d79ba615785c0804611de379d1
[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 Novell, Inc.
21 //
22 // Authors:
23 //      Peter Bartok    pbartok@novell.com
24 //
25 //
26 // $Revision: 1.22 $
27 // $Modtime: $
28 // $Log: Form.cs,v $
29 // Revision 1.22  2004/11/08 20:50:29  pbartok
30 // - Fixed arguments for updated SetTopmost method
31 //
32 // Revision 1.21  2004/11/04 14:47:58  jordi
33 // collection completion, drawing issues, missing features
34 //
35 // Revision 1.20  2004/10/29 15:55:26  jordi
36 // Menu key navigation, itemcollection completion, menu fixes
37 //
38 // Revision 1.19  2004/10/20 03:56:23  pbartok
39 // - Added private FormParentWindow class which acts as the container for
40 //   our form and as the non-client area where menus are drawn
41 // - Added/Moved required tie-ins to Jordi's menus
42 // - Fixed/Implemented the FormStartPosition functionality
43 //
44 // Revision 1.18  2004/10/18 04:47:09  pbartok
45 // - Fixed Form.ControlCollection to handle owner relations
46 // - Added Owner/OwnedForms handling
47 // - Implemented Z-Ordering for owned forms
48 // - Removed unneeded private overload of ShowDialog
49 // - Fixed ShowDialog, added the X11 incarnation of modal handling (or so I
50 //   hope)
51 // - Fixed Close(), had wrong default
52 // - Added firing of OnLoad event
53 // - Added some commented out debug code for Ownership handling
54 //
55 // Revision 1.17  2004/10/15 12:43:19  jordi
56 // menu work, mainmenu, subitems, etc
57 //
58 // Revision 1.16  2004/10/14 06:17:58  ravindra
59 // Fixed class signature. ShowDialog (Control) is not a public method.
60 //
61 // Revision 1.15  2004/10/08 08:50:29  jordi
62 // more menu work
63 //
64 // Revision 1.14  2004/10/02 19:05:52  pbartok
65 // - Added KeyPreview property
66 // - Added Menu property (still incomplete, pending Jordi's menu work)
67 // - Implemented ProcessCmdKey
68 // - Implemented ProcessDialogKey
69 // - Implemented ProcessKeyPreview
70 //
71 // Revision 1.13  2004/10/01 17:53:26  jackson
72 // Implement the Close method so work on MessageBox can continue.
73 //
74 // Revision 1.12  2004/09/23 19:08:59  jackson
75 // Temp build fixage
76 //
77 // Revision 1.11  2004/09/22 20:09:44  pbartok
78 // - Added Form.ControllCollection class
79 // - Added handling for Form owners: Owner, OwnedForms, AddOwnedForm,
80 //   RemoveOwnedForm (still incomplete, missing on-top and common
81 //   minimize/maximize behaviour)
82 // - Added StartPosition property (still incomplete, does not use when
83 //   creating the form)
84 // - Added ShowDialog() methods (still incomplete, missing forcing the dialog
85 //   modal)
86 //
87 // Revision 1.10  2004/09/13 16:56:04  pbartok
88 // - Fixed #region names
89 // - Moved properties and methods into their proper #regions
90 //
91 // Revision 1.9  2004/09/13 16:51:29  pbartok
92 // - Added Accept and CancelButton properties
93 // - Added ProcessDialogKey() method
94 //
95 // Revision 1.8  2004/09/01 02:05:18  pbartok
96 // - Added (partial) implementation of DialogResult; rest needs to be
97 //   implemented when the modal loop code is done
98 //
99 // Revision 1.7  2004/08/23 22:10:02  pbartok
100 // - Fixed handling of WM_CLOSE message
101 // - Removed debug output
102 //
103 // Revision 1.6  2004/08/22 21:10:30  pbartok
104 // - Removed OverlappedWindow style from Control, instead it's default
105 //   now is child
106 // - Made form windows OverlappedWindow by default
107 //
108 // Revision 1.5  2004/08/19 21:30:37  pbartok
109 // - Added handling of WM_CLOSE
110 //
111 // Revision 1.4  2004/08/11 22:20:59  pbartok
112 // - Signature fixes
113 //
114 // Revision 1.3  2004/08/04 21:13:47  pbartok
115 // - Added AutoScale properties
116 //
117 // Revision 1.2  2004/07/13 15:31:45  jordi
118 // commit: new properties and fixes form size problems
119 //
120 // Revision 1.1  2004/07/09 05:21:25  pbartok
121 // - Initial check-in
122 //
123 //
124
125 // NOT COMPLETE
126
127 using System;
128 using System.Drawing;
129 using System.ComponentModel;
130 using System.Collections;
131 using System.Runtime.InteropServices;
132 using System.Threading;
133
134 namespace System.Windows.Forms {
135         public class Form : ContainerControl {
136                 #region Local Variables
137                 internal bool                   closing;
138
139                 private static bool             autoscale;
140                 private static Size             autoscale_base_size;
141                 private bool                    is_modal;
142                 internal bool                   end_modal;                      // This var is being monitored by the application modal loop
143                 private IButtonControl          accept_button;
144                 private IButtonControl          cancel_button;
145                 private DialogResult            dialog_result;
146                 private FormStartPosition       start_position;
147                 private Form                    owner;
148                 private Form.ControlCollection  owned_forms;
149                 private bool                    key_preview;
150                 private MainMenu                menu;
151                 internal FormParentWindow       form_parent_window;
152                 #endregion      // Local Variables
153
154                 #region Private Classes
155
156                 // This class will take over for the client area
157                 internal class FormParentWindow : Control {
158                         #region FormParentWindow Class Local Variables
159                         internal Form   owner;
160                         #endregion      // FormParentWindow Class Local Variables
161
162                         #region FormParentWindow Class Constructor
163                         internal FormParentWindow(Form owner) : base() {
164                                 this.owner = owner;
165
166                                 this.Width = 250;
167                                 this.Height = 250;
168
169                                 BackColor = owner.BackColor;
170                                 Text = "FormParent";
171                                 this.Location = new Point(0, 0);
172                                 this.Dock = DockStyle.Fill;
173
174                                 MouseDown += new MouseEventHandler (OnMouseDownForm); 
175                                 MouseMove += new MouseEventHandler (OnMouseMoveForm); 
176                                 owner.TextChanged += new EventHandler(OnFormTextChanged);
177                         }
178                         #endregion      // FormParentWindow Class Constructor
179 \r
180                         #region FormParentWindow Class Protected Instance Methods\r
181                         protected override CreateParams CreateParams {\r
182                                 get {\r
183                                         CreateParams cp;\r
184 \r
185                                         cp = base.CreateParams;\r
186 \r
187                                         cp.Style = (int)(WindowStyles.WS_OVERLAPPEDWINDOW | 
188                                                          WindowStyles.WS_VISIBLE | 
189                                                          WindowStyles.WS_CLIPSIBLINGS | 
190                                                          WindowStyles.WS_CLIPCHILDREN);
191
192                                         cp.Width = 250;
193                                         cp.Height = 250;
194 \r
195 #if later\r
196                                         if (this.IsHandleCreated) {\r
197                                                 int     x;\r
198                                                 int     y;\r
199                                                 int     width;\r
200                                                 int     height;\r
201                                                 int     cwidth;\r
202                                                 int     cheight;\r
203 \r
204                                                 XplatUI.GetWindowPos(this.window.Handle, out x, out y, out width, out height, out cwidth, out cheight);\r
205                                                 UpdateBounds(x, y, width, height);\r
206                                                 owner.UpdateBounds(x, y, width, height);\r
207                                         }\r
208 \r
209 #endif\r
210                                         return cp;\r
211                                 }\r
212                         }\r
213 \r
214                         protected override void OnResize(EventArgs e) {\r
215                                 base.OnResize(e);
216                                 //owner.SetBoundsCore(owner.Bounds.X, owner.Bounds.Y, ClientSize.Width, ClientSize.Height, BoundsSpecified.All);
217                                 if (owner.menu == null) {
218                                         owner.SetBoundsCore(0, 0, ClientSize.Width, ClientSize.Height, BoundsSpecified.All);
219                                 } else {
220                                         int menu_height;
221
222                                         menu_height = MenuAPI.MenuBarCalcSize(DeviceContext, owner.Menu.menu_handle, ClientSize.Width);
223                                         Invalidate (new Rectangle (0, 0, ClientSize.Width, menu_height));                                       
224                                         owner.SetBoundsCore(0, menu_height, ClientSize.Width, ClientSize.Height-menu_height, BoundsSpecified.All);
225                                 }
226                         }\r
227 \r
228                         protected override void OnPaint(PaintEventArgs pevent) {\r
229                                 OnDrawMenu (pevent.Graphics);
230                         }\r
231 \r
232                         protected override void WndProc(ref Message m) {\r
233                                 switch((Msg)m.Msg) {\r
234                                         case Msg.WM_CLOSE: {\r
235                                                 CancelEventArgs args = new CancelEventArgs();\r
236 \r
237                                                 owner.OnClosing(args);\r
238 \r
239                                                 if (!args.Cancel) {\r
240                                                         owner.OnClosed(EventArgs.Empty);\r
241                                                         owner.closing = true;\r
242                                                         base.WndProc(ref m);\r
243                                                         break;\r
244                                                 }\r
245                                                 break;\r
246                                         }\r
247 \r
248                                         default: {\r
249                                                 base.WndProc (ref m);\r
250                                                 break;\r
251                                         }\r
252                                 }\r
253                         }\r
254                         #endregion      // FormParentWindow Class Protected Instance Methods\r
255 \r
256                         #region FormParentWindow Class Private Methods\r
257                         private void OnMouseDownForm (object sender, MouseEventArgs e) {                        
258                                 if (owner.menu != null)
259                                         owner.menu.OnMouseDown (owner, e);
260                         }
261
262                         private void OnMouseMoveForm (object sender, MouseEventArgs e) {                        
263                                 if (owner.menu != null)
264                                         owner.menu.OnMouseMove (owner, e);
265                         }
266                 
267                 
268                         private void OnDrawMenu (Graphics dc) {
269                                 if (owner.menu != null) {                                                                                                       
270                                         Rectangle rect = new Rectangle (0,0, Width, 0);                 
271                                         MenuAPI.DrawMenuBar (dc, owner.menu.Handle, rect);
272                                 }                       
273                         }
274                         private void OnFormTextChanged(object sender, EventArgs e) {\r
275                                 this.Text = ((Control)sender).Text;\r
276                         }\r
277                         #endregion      // FormParentWindow Class Private Methods
278                 }
279                 #endregion      // Private Classes
280
281                 #region Public Classes
282                 public class ControlCollection : Control.ControlCollection {
283                         Form    form_owner;
284
285                         public ControlCollection(Form owner) : base(owner) {
286                                 this.form_owner = owner;
287                         }
288
289                         public override void Add(Control value) {
290                                 for (int i=0; i<list.Count; i++) {
291                                         if (list[i]==value) {
292                                                 // Do we need to do anything here?
293                                                 return;
294                                         }
295                                 }
296                                 list.Add(value);
297                                 ((Form)value).owner=(Form)owner;
298                         }
299
300                         public override void Remove(Control value) {\r
301                                 ((Form)value).owner = null;\r
302                                 base.Remove (value);\r
303                         }\r
304                 }
305                 #endregion      // Public Classes
306                         
307                 #region Public Constructor & Destructor
308                 public Form() {
309                         closing = false;
310                         is_modal = false;
311                         end_modal = false;
312                         dialog_result = DialogResult.None;
313                         start_position = FormStartPosition.WindowsDefaultLocation;
314                         key_preview = false;
315                         menu = null;
316
317                         owned_forms = new Form.ControlCollection(this);
318                 }
319                 #endregion      // Public Constructor & Destructor
320
321
322                 #region Public Static Properties
323                 #endregion      // Public Static Properties
324
325                 #region Public Instance Properties
326                 public IButtonControl AcceptButton {
327                         get {
328                                 return accept_button;
329                         }
330
331                         set {
332                                 accept_button = value;
333                         }
334                 }
335                         
336                 public bool AutoScale {
337                         get {
338                                 return autoscale;
339                         }
340
341                         set {
342                                 autoscale=value;
343                         }
344                 }
345
346                 public virtual Size AutoScaleBaseSize {
347                         get {
348                                 return autoscale_base_size;
349                         }
350
351                         set {
352                                 autoscale_base_size=value;
353                         }
354                 }
355
356                 public IButtonControl CancelButton {
357                         get {
358                                 return cancel_button;
359                         }
360
361                         set {
362                                 cancel_button = value;
363                         }
364                 }
365
366                 public DialogResult DialogResult {
367                         get {
368                                 return dialog_result;
369                         }
370
371                         set {
372                                 dialog_result = value;
373
374                                 if (is_modal && (dialog_result != DialogResult.None)) {
375                                         end_modal = true;
376                                 }
377                         }
378                 }
379
380                 public bool KeyPreview {
381                         get {
382                                 return key_preview;
383                         }
384
385                         set {
386                                 key_preview = value;
387                         }
388                 }
389
390                 public MainMenu Menu {
391                         get {
392                                 return menu;
393                         }
394
395                         set {
396                                 if (menu != value) {
397                                         if (value == null) {
398                                                 form_parent_window.Width = form_parent_window.Width;    // Trigger a resize
399                                         }
400
401                                         menu = value;
402
403                                         // To simulate the non-client are for menus we create a 
404                                         // new control as the 'client area' of our form.  This
405                                         // way, the origin stays 0,0 and we don't have to fiddle with
406                                         // coordinates. The menu area is part of the original container
407                                         if (menu != null) {
408                                                 form_parent_window.Width = form_parent_window.Width;    // Trigger a resize
409                                         }
410
411                                         menu.SetForm (this);
412                                         MenuAPI.SetMenuBarWindow (menu.Handle, form_parent_window);
413                                 }
414                         }
415                 }
416
417                 public bool Modal  {
418                         get {
419                                 return is_modal;
420                         }
421                 }
422
423                 public Form[] OwnedForms {
424                         get {
425                                 Form[] form_list;
426
427                                 form_list = new Form[owned_forms.Count];
428
429                                 for (int i=0; i<owned_forms.Count; i++) {
430                                         form_list[i] = (Form)owned_forms[i];
431                                 }
432
433                                 return form_list;
434                         }
435                 }
436
437                 public Form Owner {
438                         get {
439                                 return owner;
440                         }
441
442                         set {
443                                 if (owner != value) {
444                                         if (owner != null) {
445                                                 owner.RemoveOwnedForm(this);
446                                         }
447                                         owner = value;
448                                         owner.AddOwnedForm(this);
449                                         if (owner != null) {
450                                                 XplatUI.SetTopmost(this.window.Handle, owner.window.Handle, true);
451                                         } else {
452                                                 XplatUI.SetTopmost(this.window.Handle, IntPtr.Zero, false);
453                                         }
454                                 }
455                         }
456                 }
457
458                 public FormStartPosition StartPosition {
459                         get {
460                                 return start_position;
461                         }
462
463                         set {
464                                 if (start_position == FormStartPosition.WindowsDefaultLocation) {               // Only do this if it's not set yet
465                                         start_position = value;
466                                         if (form_parent_window.IsHandleCreated) {
467                                                 switch(start_position) {
468                                                         case FormStartPosition.CenterParent: {
469                                                                 if (Parent!=null && Width>0 && Height>0) {
470                                                                         this.Location = new Point(Parent.Size.Width/2-Width/2, Parent.Size.Height/2-Height/2);
471                                                                 }
472                                                                 break;
473                                                         }
474
475                                                         case FormStartPosition.CenterScreen: {
476                                                                 if (Width>0 && Height>0) {
477                                                                         Size    DisplaySize;
478
479                                                                         XplatUI.GetDisplaySize(out DisplaySize);
480                                                                         this.Location = new Point(DisplaySize.Width/2-Width/2, DisplaySize.Height/2-Height/2);
481                                                                 }
482                                                                 break;
483                                                         }
484
485                                                         default: {
486                                                                 break;
487                                                         }
488                                                 }
489                                         }
490                                 }
491                         }
492                 }
493                 #endregion      // Public Instance Properties
494
495                 #region Protected Instance Properties
496                 [MonoTODO("Need to add MDI support")]
497                 protected override CreateParams CreateParams {
498                         get {
499                                 CreateParams cp = new CreateParams();
500
501                                 if (this.form_parent_window == null) {
502                                         form_parent_window = new FormParentWindow(this);
503                                 }
504
505                                 cp.Caption = "ClientArea";
506                                 cp.ClassName=XplatUI.DefaultClassName;
507                                 cp.ClassStyle = 0;
508                                 cp.ExStyle=0;
509                                 cp.Param=0;
510                                 cp.Parent = this.form_parent_window.window.Handle;
511                                 cp.X = Left;
512                                 cp.Y = Top;
513                                 cp.Width = Width;
514                                 cp.Height = Height;
515                                 
516                                 cp.Style = (int)WindowStyles.WS_CHILD;
517                                 cp.Style |= (int)WindowStyles.WS_VISIBLE;
518                                 cp.Style |= (int)WindowStyles.WS_CLIPSIBLINGS;
519                                 cp.Style |= (int)WindowStyles.WS_CLIPCHILDREN;
520
521                                 return cp;
522                         }
523                 }
524
525                 protected override Size DefaultSize {
526                         get {
527                                 return new Size (250, 250);
528                         }
529                 }               
530
531                 protected override void OnPaint (PaintEventArgs pevent)
532                 {
533                         base.OnPaint (pevent);
534                 }               
535                 
536                 #endregion      // Protected Instance Properties
537
538
539                 #region Public Static Methods
540                 #endregion      // Public Static Methods
541
542                 #region Public Instance Methods
543                 public void AddOwnedForm(Form ownedForm) {
544                         owned_forms.Add(ownedForm);
545                 }
546
547                 public void RemoveOwnedForm(Form ownedForm) {
548                         owned_forms.Remove(ownedForm);
549                 }
550
551                 public DialogResult ShowDialog() {
552                         return ShowDialog(null);
553                 }
554
555                 public DialogResult ShowDialog(IWin32Window ownerWin32) {
556                         Control         owner = null;
557
558                         if (ownerWin32 != null) {
559                                 owner = Control.FromHandle(ownerWin32.Handle);
560                         }
561
562                         if (is_modal) {
563                                 return DialogResult.None;
564                         }
565
566                         if (Visible) {
567                                 throw new InvalidOperationException("Already visible forms cannot be displayed as a modal dialog. Set the Visible property to 'false' prior to calling Form.ShowDialog.");
568                         }
569
570                         if (!IsHandleCreated) {
571                                 CreateControl();
572                         }
573
574                         XplatUI.SetModal(window.Handle, true);
575
576                         Show();
577
578                         is_modal = true;
579                         Application.ModalRun(this);
580                         is_modal = false;
581                         Hide();
582
583                         XplatUI.SetModal(window.Handle, false);
584
585                         return DialogResult;
586                 }
587
588                 public void Close ()
589                 {
590                         CancelEventArgs args = new CancelEventArgs ();
591                         OnClosing (args);
592                         if (!args.Cancel) {
593                                 OnClosed (EventArgs.Empty);
594                                 closing = true;
595                                 return;
596                         }
597                 }
598
599                 #endregion      // Public Instance Methods
600
601                 #region Protected Instance Methods
602                 protected override void CreateHandle() {\r
603                         base.CreateHandle ();\r
604                 }\r
605
606                 protected override void OnCreateControl() {\r
607                         base.OnCreateControl ();\r
608                         OnLoad(EventArgs.Empty);\r
609                 }\r
610
611                 protected override void OnHandleCreated(EventArgs e) {\r
612                         base.OnHandleCreated (e);\r
613                 }\r
614
615                 protected override void OnHandleDestroyed(EventArgs e) {\r
616                         base.OnHandleDestroyed (e);\r
617                 }\r
618
619
620                 protected override void OnResize(EventArgs e) {
621                         base.OnResize(e);
622                 }
623 \r
624                 protected override bool ProcessCmdKey(ref Message msg, Keys keyData) {\r
625                         if (base.ProcessCmdKey (ref msg, keyData)) {\r
626                                 return true;\r
627                         }\r
628 \r
629                         // Give our menu a shot\r
630                         if (menu != null) {\r
631                                 return menu.ProcessCmdKey(ref msg, keyData);\r
632                         }\r
633 \r
634                         return false;\r
635                 }\r
636
637                 protected override bool ProcessDialogKey(Keys keyData) {
638                         if (keyData == Keys.Enter && accept_button != null) {
639                                 accept_button.PerformClick();
640                                 return true;
641                         } else if (keyData == Keys.Enter && cancel_button != null) {
642                                 cancel_button.PerformClick();
643                                 return true;
644                         }
645                         return base.ProcessDialogKey(keyData);
646                 }
647
648                 protected override bool ProcessKeyPreview(ref Message msg) {\r
649                         if (key_preview) {\r
650                                 if (ProcessKeyEventArgs(ref msg)) {\r
651                                         return true;\r
652                                 }\r
653                         }\r
654                         return base.ProcessKeyPreview (ref msg);\r
655                 }\r
656
657                 protected override void WndProc(ref Message m) {\r
658                         switch((Msg)m.Msg) {\r
659                                 case Msg.WM_CLOSE: {\r
660                                         CancelEventArgs args = new CancelEventArgs();\r
661 \r
662                                         OnClosing(args);\r
663 \r
664                                         if (!args.Cancel) {\r
665                                                 OnClosed(EventArgs.Empty);\r
666                                                 closing = true;\r
667                                                 base.WndProc(ref m);\r
668                                                 break;\r
669                                         }\r
670                                         break;\r
671                                 }\r
672 \r
673 #if topmost_workaround
674                                 case Msg.WM_ACTIVATE: {\r
675                                         if (this.OwnedForms.Length>0) {
676                                                 XplatUI.SetZOrder(this.OwnedForms[0].window.Handle, this.window.Handle, false, false);
677                                         }
678                                         break;\r
679                                 }\r
680 #endif\r
681                                 default: {\r
682                                         base.WndProc (ref m);\r
683                                         break;\r
684                                 }\r
685                         }\r
686                 }\r
687                 #endregion      // Protected Instance Methods
688
689                 #region Events
690                 protected virtual void OnActivated(EventArgs e) {
691                         if (Activated != null) {
692                                 Activated(this, e);
693                         }
694                 }
695
696                 protected virtual void OnClosed(EventArgs e) {
697                         if (Closed != null) {
698                                 Closed(this, e);
699                         }
700                 }
701
702                 protected virtual void OnClosing(System.ComponentModel.CancelEventArgs e) {
703                         if (Closing != null) {
704                                 Closing(this, e);
705                         }
706                 }
707
708                 protected virtual void OnDeactivate(EventArgs e) {
709                         if (Deactivate != null) {
710                                 Deactivate(this, e);
711                         }
712                 }
713
714                 protected virtual void OnInputLanguageChanged(InputLanguageChangedEventArgs e) {
715                         if (InputLanguageChanged!=null) {
716                                 InputLanguageChanged(this, e);
717                         }
718                 }
719
720                 protected virtual void OnInputLanguageChanging(InputLanguageChangingEventArgs e) {
721                         if (InputLanguageChanging!=null) {
722                                 InputLanguageChanging(this, e);
723                         }
724                 }
725
726                 protected virtual void OnLoad(EventArgs e) {
727                         if (Load != null) {
728                                 Load(this, e);
729                         }
730                 }
731
732                 protected virtual void OnMaximizedBoundsChanged(EventArgs e) {
733                         if (MaximizedBoundsChanged != null) {
734                                 MaximizedBoundsChanged(this, e);
735                         }
736                 }
737
738                 protected virtual void OnMaximumSizeChanged(EventArgs e) {
739                         if (MaximumSizeChanged != null) {
740                                 MaximumSizeChanged(this, e);
741                         }
742                 }
743
744                 protected virtual void OnMdiChildActivate(EventArgs e) {
745                         if (MdiChildActivate != null) {
746                                 MdiChildActivate(this, e);
747                         }
748                 }
749
750                 protected virtual void OnMenuComplete(EventArgs e) {
751                         if (MenuComplete != null) {
752                                 MenuComplete(this, e);
753                         }
754                 }
755
756                 protected virtual void OnMenuStart(EventArgs e) {
757                         if (MenuStart != null) {
758                                 MenuStart(this, e);
759                         }
760                 }
761
762                 protected virtual void OnMinimumSizeChanged(EventArgs e) {
763                         if (MinimumSizeChanged != null) {
764                                 MinimumSizeChanged(this, e);
765                         }
766                 }
767
768                 public event EventHandler Activated;
769                 public event EventHandler Closed;
770                 public event CancelEventHandler Closing;
771                 public event EventHandler Deactivate;
772                 public event InputLanguageChangedEventHandler InputLanguageChanged;
773                 public event InputLanguageChangingEventHandler InputLanguageChanging;
774                 public event EventHandler Load;
775                 public event EventHandler MaximizedBoundsChanged;
776                 public event EventHandler MaximumSizeChanged;
777                 public event EventHandler MdiChildActivate;
778                 public event EventHandler MenuComplete;
779                 public event EventHandler MenuStart;
780                 public event EventHandler MinimumSizeChanged;
781                 #endregion      // Events
782         }
783 }