Form Maximize Events
-
I have a form that is being maximized. The form is a child form of an MDI parent and there is another child form docked on the left as a menu. Therefore, when the form is maximized it needs to be maximized to (for instance:) location 256, 0, 200, 200 instead of 0,0,456,200 (where above is x, y, width, height). I'm having a real issue finding an event that fires BEFORE a maximize command to set the bounds and the maximizedbounds property doesn't seem to be doing any good. Any ideas, events, etc.? Brian "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." - Douglas Adams
-
I have a form that is being maximized. The form is a child form of an MDI parent and there is another child form docked on the left as a menu. Therefore, when the form is maximized it needs to be maximized to (for instance:) location 256, 0, 200, 200 instead of 0,0,456,200 (where above is x, y, width, height). I'm having a real issue finding an event that fires BEFORE a maximize command to set the bounds and the maximizedbounds property doesn't seem to be doing any good. Any ideas, events, etc.? Brian "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." - Douglas Adams
Override
WndProc
and handle theWM_SIZING
(0x0214) message. This is sent to a window procedure (and keep in mind that almost all Windows Forms controls encapsulate native controls and dialogs) before being resized. TheMessage.WParam
specifies the edge that is being resized and theMessage.LParam
specifies theRECT
(which you must define in managed code - aSystem.Drawing.Rectangle
will not suffice because it stores coordinates differently). Set theMessage.Result
tonew IntPtr(1)
to signal that you've processed it and don't want yourForm
to be resized.Microsoft MVP, Visual C# My Articles