Game Development Reference
In-Depth Information
BOOL CMFCDialogApp::InitInstance()
{
//Only use AfxEnableControlContainer if you intend to use ActiveX
//controls in the dialog
AfxEnableControlContainer();
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC
// statically
#endif
CMFCDialogDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
// Since the dialog has been closed, return FALSE so that we
// exit the application, rather than start the application's
// message pump.
return FALSE;
}
Notice that the main window is the
Dialog class CMFCDialogDlg , which is
derived from CDialog . A dialog box is
shown using the member function
DoModal . When a dialog box is closed,
DoModal returns the ID of the control
that closed it. The default implementa-
tion uses the buttons OK and Cancel,
which return IDOK and IDCANCEL.
Figure B.3 A simple Dialog-based
application.
 
Search Nedrilad ::




Custom Search