Drawing own maximize button

  • Thread starter Thread starter Navneet
  • Start date Start date
N

Navneet

Hi,

I have a MDI application and I want to have only One
particular form to allow user to maximize say "MyMaxForm".

Now even if I disable the maximize button of all other
forms than after the user have maximised the "MyMaxForm"
and then he opens another form it opens maximised in MDI.

Therefore I do not want to display the maximise button
on "MyMaxForm" and want to draw my own button there so
that I can just resize the form with the clientsize and
the form's state will still be normal.Thus, any other form
if opened later will not open maximized.

Now If I subclass the form and implement the OnPaint
method I can draw a button but it will always draw it
under the title label of the form. I want to draw the
button next to the X (form close) button at the top.

Is there any way to do this. Or any other way I can
achieve my goal.

Thanks
Navneet
 
Drawing your own maximize button would be a lot of work. Trust me, I've
seen code that tries to do custom draw of the form caption -- getting it
right is quite painful. I'd suggest that instead, you catch the
notification when the user presses the existing maximize button, and
override the default Windows behavior for that button.

To do this, you need to override the form's WndProc and look for the
WM_SYSCOMMAND message. If you get an SC_MAXIMIZE, then you do your own
thing and don't call base.WndProc(); otherwise you do call base.WndProc().
Note the part about masking out the lower four bits.

Here are a couple of posts that should put you on the right track (watch the
line breaks):

http://groups.google.com/groups?hl=...group%3Amicrosoft.public.dotnet.*+sc_maximize

http://groups.google.com/[email protected]&rnum=1
 
Back
Top