My customer want me to change the default maximise-buttons functionality to maximise the form over all screens the customer have. I have already written some code to measure the correct rectangle to put the form to, but when i assign it to the MaximisedBounds attribute of the form, there are some issures: The screen (in my 2 screen tests) that the form was not on before the click get only one paint, ans if you click on the form on the other screen it is like you have clicked “under” it onto the next window beneath.
Of course there are other ways to solve this problem (like in Event when a window gets maximized/un-maximized), i wounder if the described behaviour is a bug, or my mistake. Is there anything to do before changing the MaximisedBounds attribute to make it work?
I’d agree with Matt. Setting the “MaximizedBounds” is not a good idea.
As written in Event when a window gets maximized/un-maximized, I would override the WndProc-method. There you can handle the different received commands from your window on your own.
The main thing to do is to write your own code for the “SC_MAXIMIZE”-windowcommand (as written in the referenced article above). There you can manually set the form’s size e.g. In this case the form won’t be really maximized. Actually is it still in normal WindowState. To prevent the user from changing this state you need to “catch” some other windowcommands.
The overridden WndProc method could be like this: