Click to See Complete Forum and Search --> : Which message maps/function should I use to create a dialog/window automatically when apps starts up


tguha
May 19th, 1999, 10:04 PM
Can anybody provide me a source code in VC++5.0, which will create a MDI window and a dialog box automatically when the application starts up. I have some problem in doing that. I could'n figure out in what function/message map I can write that piece of code, wherever I do that, the window always getting covered by View window in one way or the other. Any help or clue is most welcome.

Senior Consultant Cap Gemini America,LLC

May 19th, 1999, 10:22 PM
Do following:
Create new project "sam", choose MDI in Step 1. Click finish
Create Dialod you want to display when app start.
In samApp class
Include "Dialog.h"
In InitInstance()
{
CDialog *dlg = new CDialog();
dlg->Create(CDialog::IDD);
dlg->ShowWindow(SW_SHOW);
// when you want show MDI call dlg->DestroyWindow();
}
LB_TMA

Dan Haddix
May 20th, 1999, 02:08 AM
If you use DoModal instead of ShowWindow it will insure your dialog will stay on top of your main window.

Lac Bui
May 20th, 1999, 09:13 PM
Sorry. But you use ShowWindow that mean you use Modalless, MDI continue work while the Dialog show. Use DoModal the program will wait untill Dialog hide to continue.

LB_TMA

Saeed R
May 20th, 1999, 09:52 PM
Not to mention that

BOOL CTestApp::InitInstance()
{
AfxEnableControlContainer();

CDtest dlg; //add this line
dlg.DoModal();//and this line



works as well