• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 388
  • Last Modified:

How to Hide a dialog on App startup

I have an application that's main window is a dialog box.  It has a taskbar icon associated with it.  How do I hide the window at the start of the application?  I tried to call ShowWindow() in the Create, OnCreate, and InitDialog with no luck.  Also, I tried to set the m_nCmdShow of the dialog in the App Class with no luck.
0
healer
Asked:
healer
1 Solution
 
migelCommented:
Hi! You can use SetWindowPos function with SWP_HIDEWINDOW.
0
 
nil_dibCommented:
Did you try ShowWindow(SW_HIDE) ?
0
 
wyy_cqCommented:
in the yourDlg::OnInitDialog
{
 ...
 ShowWindow(SW_HIDE);
 return FALSE;
}
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
healerAuthor Commented:
I tried calling the ShowWindow(SW_HIDE) in the OnInitDialog and then returning FALSE,  The dialog still shows up.
0
 
joshualCommented:
You can only call ShowWindow(SW_HIDE) after the Dialog is created and not at OnInitDialog. I did it but setting a 10msec timer at OnInitDialog and call ShowWindow at OnTimer.

You might see the Dialog blink once. This can be overcome by moveing the dialog out of the screen.

0
 
migelCommented:
You Can create modeless dialog (do not forget turn off WS_VISIBLE style)
0
 
wyy_cqCommented:
set a timer in OnInitDialog...
{
  SetTimer(1,1,NULL);
  PostMessage(WM_SYSCOMMAND,SC_MINIMIZE ,0);//optional
..
}

defien timer handler
XXX::OnTimer(...)
{
  KillTimer(1);
  ShowWindow(SW_HIDE);
  ....
}
0
 
dagangwangCommented:
1. Create a window without "WS_VISIBLE" style;
2. In this window, create your dialog. This window is dialog's parent window;
    Thus, initial window is not visible, dialog is not visible also.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now