In my application I need to temporarily gray out the minimize button of the main form. Any ideas how this can be achieved? I don\'t mind doing p/invokes to Win32 dlls.
Just do MinimizeBox = false; in your form's code.
You can also implement handle to the Minimize event to cancel the command
Coincoin's answer is correct. MinimizeBox is also available as a property in the designer properties window.
@Kevin: While I appreciate the sentiment, that's not always a valid answer. If the application displays a modal dialog box by creating a new instance of a Form and then calling .ShowDialog() on it, you don't want the user to minimize that Form, because then all input on the main UI thread is blocked until that Form's modal status is satisfied. The user could potentially click on the main form and just get the "ding ding ding" unresponsive sound from Windows and not know what to do.
Put this code in your form's Resize event:
if (this.WindowState == FormWindowState.Minimized)
{
this.WindowState = FormWindowState.Normal;
}
This will make your form un-minimizable (DISCLAIMER: I do not advocate altering the standard behavior of windows in this way).
form.MinimizeBox = false;
or if in the form scope
MinimizeBox = false;
Don't. Don't mess with my windows. They are mine, not yours. It is my computer and if I want to minimize, I should be able to. I can't think of, and have never been given, a good reason for doing this.