Join the project
For example, as follows:
1. Add the MFC class CMYMAINSHEET to the project, select CPropertySheet as its base class.
2. Add MFC Class CMYPAGE1, CMYPAGE2, select CPropertyPage as base classes, which will be used as the property page in the Properties dialog.
Pop-up attribute dialog
achieve:
Void PopuPropertydlg ()
// Create PropertySheet and PropertyPage
CMYMAINSHEET MMS (_T ("mainsheet"), this);
CMYPAGE1 MP1;
CMYPAGE2 MP2;
// If you want to remove the "Application" and "Help" button
MMS.M_PSH.DWFLAGS | = PSH_NOAPPLYNOW;
MMS.M_PSH.DWFLAGS & = ~ PSH_HASHELP;
Mp1.m_psp.dwflags & = ~ psp_haashelp;
Mp2.m_psp.dwflags & = ~ psp_haashelp;
/ / Set the initial value of the elements in each property page
mp1.m_xxxx =;
Mp2.m_xxxx =;
// pop-up dialogue box
MMS.ADDPAGE (& MP1);
MMS.ADDPAGE (& MP2);
IF (MMS.Domodal () == iDOK)
/ / If it is determined, the action taken
// Note that Updatedata (true) has been automatically executed when the code is executed.
Interaction between various elements in PropertySheet
In a complex dialog, there is often a case where there is a case where the control is modified, the value of the element affects other controls in the property page, or even the properties of the controls in other property pages. If you are processed by a method such as direct message, such processing logic will spread all attribute pages, reduce the readability and modification of the code. We use PropertySheet as a mediator, so messages are sent to the PropertySheet and then processed by the controls in the PropertyPage involved.
For example, whether to fill in the value in the EDIT of the MP1 control to affect the enable / disable of the Edit control in MP2, we can do this:
Add a message response function in CMYPAGE1 to receive an EDIT control modification event
OnenchangeEdit ()
Call the pro processing function of the PropertySheet, not yourself
CMYMAINSHEET * PMMS = NULL;
PMMS = (CMYMAINSHEET *) getParent ();
PMMS-> enableswitch ();
Add to process functions in CMYMAINSHEET
Enableswitch
Determine the value of the control in the MP1 to determine the enable / disable of the control in MP2.
CString str1;
GetPage (0) -> getdlgitemtext (idc_edit1, str1);
IF (_t (") == STR1)
GetPage (1) -> getdlgitem (idc_edit1) -> EnableWindow (FALSE);
Else
GetPage (1) -> getdlgitem (idc_edit1) -> EnableWindow (TRUE);