Home All Groups Group Topic Archive Search About

Using WindowState for starting forms minimized problem

Author
23 Nov 2004 7:19 PM
Kentonis
I have an application with several Form based windows.  I want to be able to
start the application minimized, so I have a command line parameter to set
WindowState to Minimized. 

I set the window state in the OnCreateControl (because if I do it in the
constructor there are some sizing issues) and the window starts minimized. 
However, when I restore the window, most of the forms are blank (save for the
last one added).  I can see through the debugger that the WindowState is now
Normal, but none of the child controls show.

The app is being restored to the normal size by using ShowWindow( hwnd,
SW_NORMAL), which appears to set all the forms to Normal.  I see the app
visually return to normal but only one of the child does so properly.

How are the WindowState property and the ::ShowWindow method related? 

Any suggestions on a better way to handle this?

/ken

Author
23 Nov 2004 7:45 PM
Kentonis
I am wondering where the proper place is to set the WindowState to minimized. 

If I create a shortcut, I can set the Run property to Minimized.  Is this
the same as using the shell "Start /min myapp.exe" from a command prompt? 
This doesn't seem to cause any sizing problems for my apps forms.

How does this set the WindowState to minimized and what else is performed by
the shell command?  (Is it just sending a WS_MINIMIZE message to the app and
if so, how can I replicate this internally using WindowsState?)

/ken
Author
23 Nov 2004 11:28 PM
Tom Krueger [MSFT]
Hello,

Can you just do the following in the FormLoad?
this.WindowState = FormWindowState.Minimized;

I'm curious what the purpose of this application is and why it is minimized
on startup?


--
Tom Krueger

Smart Client DevCenter - http://msdn.microsoft.com/smartclient/
Mobile DevCenter - http://msdn.microsoft.com/mobility

This posting is provided "as is" with no warranties and confers no rights.

Show quote
"Kentonis" <Kento***@discussions.microsoft.com> wrote in message
news:B2172B11-DF40-4253-A711-82FFA0B3A93F@microsoft.com...
>I have an application with several Form based windows.  I want to be able
>to
> start the application minimized, so I have a command line parameter to set
> WindowState to Minimized.
>
> I set the window state in the OnCreateControl (because if I do it in the
> constructor there are some sizing issues) and the window starts minimized.
> However, when I restore the window, most of the forms are blank (save for
> the
> last one added).  I can see through the debugger that the WindowState is
> now
> Normal, but none of the child controls show.
>
> The app is being restored to the normal size by using ShowWindow( hwnd,
> SW_NORMAL), which appears to set all the forms to Normal.  I see the app
> visually return to normal but only one of the child does so properly.
>
> How are the WindowState property and the ::ShowWindow method related?
>
> Any suggestions on a better way to handle this?
>
> /ken
>
>

AddThis Social Bookmark Button