Link to home
Start Free TrialLog in
Avatar of healer
healer

asked on

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.
Avatar of migel
migel

Hi! You can use SetWindowPos function with SWP_HIDEWINDOW.
Did you try ShowWindow(SW_HIDE) ?
in the yourDlg::OnInitDialog
{
 ...
 ShowWindow(SW_HIDE);
 return FALSE;
}
Avatar of healer

ASKER

I tried calling the ShowWindow(SW_HIDE) in the OnInitDialog and then returning FALSE,  The dialog still shows up.
ASKER CERTIFIED SOLUTION
Avatar of joshual
joshual

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You Can create modeless dialog (do not forget turn off WS_VISIBLE style)
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);
  ....
}
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.