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.
Hi! You can use SetWindowPos function with SWP_HIDEWINDOW.
Did you try ShowWindow(SW_HIDE) ?
in the yourDlg::OnInitDialog
{
...
ShowWindow(SW_HIDE);
return FALSE;
}
{
...
ShowWindow(SW_HIDE);
return FALSE;
}
ASKER
I tried calling the ShowWindow(SW_HIDE) in the OnInitDialog and then returning FALSE, The dialog still shows up.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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_MINIMIZ E ,0);//optional
..
}
defien timer handler
XXX::OnTimer(...)
{
KillTimer(1);
ShowWindow(SW_HIDE);
....
}
{
SetTimer(1,1,NULL);
PostMessage(WM_SYSCOMMAND,
..
}
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.
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.