Creating an MFC property sheet

Source: Internet
Author: User

A property sheet consists of one or more property pages. It effectively solves a large amount of information that cannot be displayed on a dialog box.

1. Create a property page

In order to create a property sheet, you first need to create a property page, which corresponds to an MFC class CPropertyPage, which represents a separate property page in the property sheet.

Add 3 Property Page resources under the resource compiler and modify the ID and caption (Caption property) of the three property page resources, and the title of the property page is the name of the tab that will eventually be displayed on the property page. There are three types of property pages,

Note: If you know the attribute difference between a property page resource and a dialog resource, you can also add a normal dialog resource to your program, and then modify its properties to conform to the property page resource requirements and use it as a property page resource.

The corresponding property page class is generated for each property page, and the base class is CPropertyPage.

2. Create a property sheet

In order to create a property sheet, you first need to create an object, then create an object (CPropertyPage type) for each property page in this object, and call the AddPage function to add each property page, and then call the DoModal function to display a modal property sheet, or call the CREATE function to make a non-modal property sheet.

(1) Create a class Cpropsheet with a base class of CPropertySheet.

(2) A member variable is defined in the Cpropsheet class header file for the three previously created property pages. Note include the corresponding header file.

CProPage1 M_page1; CProPage2 M_page2; CProPage3 M_page3;

(3) Add Property Page object.

It is common to add Property page objects in the property sheet's constructor. The property sheet has two constructors:

Cpropsheet::cpropsheet (UINT nidcaption, cwnd* pParentWnd, uint iselectpage)    : CPropertySheet (Nidcaption, pParentWnd, Iselectpage) {}cpropsheet::cpropsheet (LPCTSTR pszcaption, CWnd* pParentWnd, UINT iselectpage)    : CPropertySheet (pszcaption, pParentWnd, iselectpage) {}

ISELECTPAGE Specifies the property sheet for the initial selection of the property form, and the default value is the first page. Because the property sheet has two constructors, you can select one of the constructors when you construct the property sheet object.

Cpropsheet::cpropsheet (LPCTSTR pszcaption, cwnd* pParentWnd, UINT iselectpage)    : CPropertySheet (PszCaption, pParentWnd, iselectpage) {    AddPage (&m_page1);    AddPage (&m_page2);    AddPage (&m_page3);}

(4) Display the property sheet.

The CPropertySheet class derives from the CWnd class, not the CDialog class. However, the CPropertySheet object operates in a similar manner to the CDialog object. Call the DoModal function to display a modal property sheet, or call the CREATE function to make a non-modal property sheet.

If you want to display the property sheet at initialization time, you need to manipulate it in the OnInitDialog function:

Creating an MFC property sheet

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.