Cancel WinForm Collapse?

I have winform with minimMaximizeClose buttons disabled, but still, if someone clicks it on the taskbar, this will be minimized. I want to prevent this.

How can i do this?

+4
source share
4 answers

You could probably hook them in SizeChanged and check WindowState if it is set to Minimized , then set it to Normal . Not the most elegant solution, but should work.

eg.

private void myForm_SizeChanged(object sender, System.EventArgs e) { if (myForm.WindowState == FormWindowState.Minimized) { myForm.WindowState = FormWindowState.Normal; } } 
+3
source

Override WndProc in your form, listen for minimum message details, and cancel.

Add this code to the form:

 private const int WM_SYSCOMMAND = 0x0112; private const int SC_MINIMIZE = 0xf020; protected override void WndProc(ref Message m) { if (m.Msg == WM_SYSCOMMAND) { if (m.WParam.ToInt32() == SC_MINIMIZE) { m.Result = IntPtr.Zero; return; } } base.WndProc(ref m); } 

I changed Rob code found in this SO thread:
How to disable the minimize button in C #?

Works great: no flickering, there is nothing when a user tries to minimize it.

+15
source

If this suits you, just hide it from the taskbar: ShowInTaskbar=false

0
source

you can simply remove the minimize button from the window:

add the code below to the private method InitializeComponent () of the Form class:

  this.MinimizeBox = false; 
0
source

All Articles