Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

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



  1. On the Controls toolbox, click the Check Box button and click anywhere on the
    dialog

  2. Create or Add A New Class for the IDD_G3D dialog box
    Name it CGeome3D
    Base it on the CPropertyPage class

  3. Change the design of the IDR_MAINFRAME icon as follows:

  4. Save All


12.3.3..Property Sheets....................................................................................


To implement its functionality, the property pages are put together and kept as an entity
by an object called a property sheet. The property sheet acts as their parent. Like other
controls, we will see that the property pages must be added to a property sheet.

There is no resource to create for a property sheet. A property sheet is based on the
CPropertySheet class, which is not based on CDialog but it provides the same
functionality as dialog. Therefore, a property sheet is sometimes called, or referred to as,
a dialog box. Instead, CPropertySheet is based on the CWnd class. Therefore, to
implement your property page(s), you can simply declare a CPropertySheet variable and
use it to display the application or you can programmatically derive a class from
CPropertySheet. The CPropertySheet class is declared in the afxdlgs.h header file.

If you decide to directly use the CPropertySheet class, declare a variable for it where the
application will need to be displayed or instantiated, which could be in the
CWinApp::InitInstance() event. To display the property sheet, call its DoModal()
method. This could be done as follows:

BOOL CMyApp::InitInstance()
{
CPropertySheet MySheet;

MySheet.DoModal();
}
Free download pdf