minimize by code ?
how can i minimze a form by code.
i still want my form to be on the 'running programs' list.
10X,
how can i minimze a form by code.
i still want my form to be on the 'running programs' list.
10X,
i dont know in which environment you are working, but in my Compact Framework 1.1 there are only 2 windows states:
FormWindowState.Maximized and FormWindowState.Normal
There isn't a purely managed way of doing this, but you can p/invoke to call SetWindowPos() to change the z-order of your window to get the same behavoir as when a user clicks on the (X) of a form.
mike
WM 5.0
Declare
Function ShowWindow Lib "CoreDLL.dll" (ByVal hWnd As IntPtr, ByVal nCmdShow As Long) As BooleanShowWindow(Me.Handle, 6)
[DllImport ("coredll.dll")]
private static extern bool SetForegroundWindow(IntPtr hWnd);
[DllImport ("coredll.dll")]
private static extern IntPtr GetDesktopWindow();
then call:
SetForegroundWindow(GetDesktopWindow());
Unfortunately, this places the form behind the Today screen by bringing the Today screen to the foreground. This means all other forms that were in front of the Today screen are minimized as well. A solution, but not an ideal solution. Could someone post SetWindowPos code that actually works?
The ShowWindow function creates an even bigger problem, since it doesn't place the form behind the Today screen unless it is the only non-minimized form. It simply moves the screen one form lower in the z-order. It activates the form just below it; when you close or minimize it the original form is activated again. This is not the expected behaviour of a Smart Minimized form.
Just for closure, this thread is answered here.