Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hide Modal Dialog at Startup

Status
Not open for further replies.

JoshT172

Programmer
Jul 11, 2002
13
US
Is there any way to hide the main window (which is also modal) at startup (so that it does not display at all, in a way that the user will not see it until he requests it) in an MFC application? I've tried the SetWindowPos and ShowWindow(SW_HIDE) methods and none of them work. I've even set the dialog's visible property to false! Why does it still show up? Someone please tell me how to get this to work.
 


I doubt it. Even if there was, why would you? The idea behind the Modal dialog is so the use has to finish with it before moving on. If you were to hide it, it would not show but the code would be stuck waiting for user input so your application would be frozen.

What you want is a ModalLess dialog. Create it and hide it in OnInitDialog() in your first Modal dialog. Then show it when the user requests it. Over ride OnCancel() in the Modaless dialog, remove CDialog::OnCancel(), and put ShowWindow(FALSE). This way the dialog will hide itself and the first Modal dialog will display it.

Brother C
 
Alright. Thanks for the help. I didn't know that Model dialogs had to be shown. I was trying to make an application that doesn't show it's main window unless the user requested it.
 
You could change the InitInstance() method in the app where the modal dialog is created to create a modeless dialog but not show it. However, ensure you return true if all goes well, else the application will not start.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top