Click to See Complete Forum and Search --> : Starting a dialog minimized or hidden: how can I do it?
Cesario Simões
April 16th, 1999, 01:09 PM
I`m starting a dialog using DoModal but, although the "visible" style is not checked the dialog appear visible! I want start it minimized or not visible but, if I use "ShowWindow (SW_HIDE);" in OnInitDialog(); the dialog appear during a little time... Someone can help me?
Cesario Simões, Jr.
Michael Decker
April 16th, 1999, 01:19 PM
DoModal() is the correct function to display a dialog box. That 'visible' flag being off is the reason you have to do DoModal() after creating one of your dialog objects.
The OnInitDialog() function is meant to be called when your dialog box gets displayed. So hiding it again within that function doesn't make sense.
If you need to do something with you dialog class, then do it before calling DoModal().
CYourDlgClass dlg; // create a dialog object
// now do something with the dialog object as you would any other class
// now display the dialog
dlg.DoModal();
Does that help?
Cesario Simões
April 16th, 1999, 02:16 PM
I want a hidding dialog because my application is dialog based and I`m using a tray icon...
I have tested your sugestion:
CAgendaDlg dlg;
here--> dlg.ModifyStyle (NULL, WS_VISIBLE, NULL);
int nResponse = dlg.DoModal();
but an erro occurs when the program execute it... I also have tested
dlg.ShowWindow(SW_HIDE); but the same error occurs...
Cesario Simões, Jr.
April 16th, 1999, 04:23 PM
I don't know exactly how I did it, but I had the same problem, and after some queries I got some answers that basically helped me.
In my dialog based application I've got a function called DisplayWindow and a function called OnWindowPosChanging.
These functions look like
void MyDialog::DisplayWindow(BOOL bShow)
{
if (bShow) {
m_bVisible = TRUE;
ShowWindow(SW_SHOWNORMAL);
}
else {
m_bVisible = FALSE
ShowWindow(SW_HIDE);
}
}
void MyDialog::OnWindowPosChanging(WINDOWPOS* lpwndpos)
{
if (!m_bVisible) lpwndpos->flags &= ~SWP_SHOWWINDOW;
CDialog::OnWindowPosChanging(lpwndpos)
}
In my OnInitDialog member function I simply call DisplayWindow(FALSE) to hide the dialog upon startup.
Obviously, you have to declare m_bVisible as a variable of your MyDialog class.
Hope this helps,
Regards,
Rob
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.