How to force a form to stay maximized and immovable all the time

G

Gerhard Menzl

I am developing a Windows Forms application that is supposed to stay
maximized and immovable all the time. Unfortunately, this approach:

WindowState = FormWindowState::Maximized;
MaximizeBox = false;

does not work. While the first statement does maximize the window, the
second one causes it to remain movable nevertheless. Leaving the
MaximizeBox property at its default value (true) achieves standard
Windows behaviour (a maximized window cannot be moved), but it allows
the user to restore the unmaximized size, which violates the specification.

Since I cannot remember having encountered this problem with the
original Windows API, I suspect it is a Windows Forms glitch, but I may
be wrong. Does anyone know a technique that achieves what I want and
does not involve overriding Move events or similar contortions?

A second problem I stumbled across is how to determine the client area
of the maximized window. Setting the WindowState property to maximized
does not change any of the size-related properties until the next Resize
event, no matter how often you call ResumeLayout or Refresh. Is
postponing operations that depend on the maximized size the only option,
or is there a way to determine the maximized window size right away?
 
G

Gerhard Menzl

Peter said:
Try setting the TopMost property to true.

"A top-most form is a form that overlaps all the other forms even if it
is not the active or foreground form. Top-most forms are always
displayed at the highest point in the Z-order of an application. You can
use this method to create a form that is always displayed in your
application, such as a Find and Replace tool window."

Sorry, but I don't want my form to be always on top. I want it
maximized, immovable, unrestorable and unminimizable. I don't see what
the TopMost property has got to do with any of these goals.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top