Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

how to insert a dialog box which prompt the user enter the general information in the SDI application?

Im using the SDI application to build a system and now i would like to insert a dialog box which allow the user to enter the general information about themselves and then it will be saved into a text file. How to insert the dialog box and show the dialog box at the beginning of the program.
0 Kudos
Message 1 of 2
(2,933 Views)
Hi Lee,

The easyest way to achieve this is to declare an object of your dialog box derived class (e.g. CUserInfo, public CDialog) into the InitInstance method of the main application class.
Depending on the behavior you want you can place the code before dispatching the commands from command line (in which case the main frame of the SDI application will not be shown), or after, in which case the UserInfo dialog box will be shown over the main application window as modal.
The code snipped bellow can be more helpfull:
BOOL CSDIApp::InitInstance()
{
AfxEnableControlContainer();
....
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);

//////////////////////////////////////
////////
//prompt user for data
CUserInfo dlg;
if (dlg.DoModal() == IDOK)
{
//do something here with the data
}
else
return FALSE;//i.e. quit the application if the user presses the 'Cancel' button
////////////////////////////////////////////
// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;

// The one and only window has been initialized, so show and update it.
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();

return TRUE;
}


Hope this helps,
Silvius
Silvius Iancu
0 Kudos
Message 2 of 2
(2,933 Views)