Show restore button without Maximize button

I want the user not to enlarge the Windows Form to full screen, so I disabled the Maximize button. However, I want the user to "restore" the form. When they click the Restore button, I want it to show a different, smaller, smaller shape that will show them a maximize button that will return the usage to its original shape.

Is there a way to do this?

Thank.

edit: You don't understand, I am not preventing the user from resizing the form. What happens when the "Restore" button is clicked, it will hide the form and open a new one with fewer controls. When they click maximize on a smaller shape, it will revert to its original shape.

+1


source to share


5 answers


I was looking at a similar issue with this at work, and the only solutions I could find involved setting undocumented window styles, which I didn't want to do.

So the best solution to your problem I would think is to hide the current minimize / enlarge / restore buttons and add your own using some ownerdraw commands or other commands.



Looking at this from a user experience perspective, I'd like the min / maximize / restore buttons to do the same for your application as they do for everyone else. Overriding this functionality would create confusion for your users, so I would recommend creating various buttons, either in the title bar or somewhere else on your interface, that perform this function.

+2


source


FWIW, the correct answer is to properly resize the form, adapt to any window size, and not limit the user to what looks right on your display at your resolution and your font size. Immutable windows are one of the most annoying things I come across in an application (Windows itself is full of them).



+1


source


You can set MaximumSize and MinimumSize and enable the maximize button to get this effect.

0


source


I have had a similar situation lately and in terms of UI design I found a good example in Windows Media Player. It leaves the Minimize, Maximize, and Restore buttons as they are, and has a separate button at the bottom right for Switch to Compact Mode. And in mini / compact mode, the same button switches to "Switch to full mode". Another alternative example is Skype, which has an extra system icon button to the left of the standard minimize button that toggles between Compact and Standard modes.

(If I had the privilege, I'd rather put this as a comment to add to Daemin's accepted answer, but relatively new to StackOverflow)

0


source


"Recovering" the form fires an event Resize

where you can check to see if the parent form is FormWindowState.Maximized

. If not, you can open the child form and hide the parent.

To reverse this, you can "maximize" the child form by hiding (or deleting) it, then disable and set the parent form to FormWindowState.Maximized

.

The only problem I see with this method is that the event Resize

will most likely fire multiple times before the form reaches the Maximumized state. The flag may be required to ignore them until the form transitions from the current state to the desired state, which could cause an infinite loop.

0


source







All Articles