Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Visual C++ and MFC Fundamentals Chapter 12: Dialog-Based Windows


Practical Learning: Creating a Wizard



  1. Open Windows Explorer or My Computer and display the contents of the parent
    folder that holds the previous exercise

  2. In the right frame, right-click Geometry and click Copy

  3. Right-click an unoccupied area in the same right frame and click Paste

  4. Rename Copy of Geometry to WizardPages

  5. Open the WizardPages project or solution

  6. Access the CGeometry::InitInstance() event and change it as follows:


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

// Standard initialization

#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif

CGeomeSheet GeoSheet("Geometric Calculations");

CQuadrilateral Quad;
CCircular Circ;
CGeome3D G3D;

GeoSheet.AddPage(&Quad);
GeoSheet.AddPage(&Circ);
GeoSheet.AddPage(&G3D);

m_pMainWnd = &GeoSheet;

GeoSheet.SetWizardMode();

int nResponse = GeoSheet.DoModal();
if (nResponse == IDOK)
{
}
else if (nResponse == IDCANCEL)
{
}

// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}


  1. Test the application

Free download pdf