Home | Overview | How Do I | FAQ | Tutorial | Sample
Occasionally, an ActiveX control will have more properties than can reasonably fit on one property page. In this case, you can add property pages to the ActiveX control to display these properties.
This article discusses adding new property pages to an ActiveX control that already has at least one property page. For more information on adding stock property pages (font, picture, or color), see the article ActiveX Controls: Using Stock Property Pages.
The following procedures use a sample ActiveX control framework created by ControlWizard. Therefore, the class names and identifiers are unique to this example.
For more information on using property pages in an ActiveX control, see the following articles:
Note It is strongly recommended that new property pages adhere to the size standard for ActiveX control property pages. The stock picture and color property pages measure 250x62 dialog units (DLUs). The standard font property page is 250x110 DLUs. The default property page created by ControlWizard uses the 250x62 DLU standard.
To create another property page
This example uses IDD_PROPPAGE_NEWPAGE
.
Make sure that on the Styles tab the Titlebar option is not checked, and on the More Styles tab the Visible option is not checked.
(In this example, CAddtlPropPage
.)
To allow the control’s users access to this new property page, make the following changes to the control’s property page IDs macro section (located in the control implementation file):
BEGIN_PROPPAGEIDS(CSampleCtrl, 2)
PROPPAGEID(CMyPropPage::guid)
PROPPAGEID(CAddtlPropPage::guid)
...
END_PROPPAGEIDS(CSampleCtrl)
Note that you must increase the second parameter of the BEGIN_PROPPAGEIDS macro (the property page count) from 1 to 2.
You must also modify the control implementation file (.CPP) file to include the header (.H) file of the new property page class.
The next step involves creating two new string resources that will provide a type name and a caption for the new property page.
To add new string resources to a property page
This opens the string table in a window.
This opens a String Properties page showing Caption and ID boxes. The Caption box contains the string you typed.
For example purposes, we’ve used IDS_SAMPLE_ADDPAGE for the type name of the new property page.
CAddtlPropPage
) modify the CAddtlPropPage::CAddtlPropPageFactory::UpdateRegistry
so that IDS_SAMPLE_ADDPAGE is passed by AfxOleRegisterPropertyPageClass, as in the following example:
BOOL CAddtlPropPage::CAddtlPropPageFactory::UpdateRegistry(BOOL bRegister)
{
if (bRegister)
return AfxOleRegisterPropertyPageClass(AfxGetInstanceHandle(),
m_clsid, IDS_SAMPLE_ADDPAGE);
else
return AfxOleUnregisterClass(m_clsid, NULL);
}
CAddtlPropPage
so that IDS_SAMPLE_ADDPPG_CAPTION is passed to the COlePropertyPage constructor, as follows:
CAddtlPropPage::CAddtlPropPage() :
// ****** Add your code below this line ********** //
COlePropertyPage(IDD, IDS_SAMPLE_ADDPPG_CAPTION)
// ****** Add your code above this line ********** //
{
//{{AFX_DATA_INIT(CAddtlPropPage)
// NOTE: ClassWizard will add member initialization here
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_DATA_INIT
}
After you have made the necessary modifications rebuild your project and use Test Container to test the new property page. For more information on testing an ActiveX control with Test Container, see Test Container.