Add ActiveX property page

Source: Internet
Author: User

ActiveX property page can be added in two situations:

  1. Add inherent property page
  2. Add custom property page

1. Add an inherent property page

MFC provides three inherent property pages for ActiveX Controls: clsid_ccolorproppage, clsid_cfontproppage, and clsid_cpictureproppage. They represent three property pages: color, Font, and image. To add them to the control, you only need to add their IDs to the initialization code of the ID array on the control property page. For
Example

BEGIN_PROPPAGEIDS(CMyAxOptCtrl, 4)   PROPPAGEID(CMyAxOptPropPage::guid)   PROPPAGEID(CLSID_CFontPropPage)   PROPPAGEID(CLSID_CColorPropPage)   PROPPAGEID(CLSID_CPicturePropPage)END_PROPPAGEIDS(CMyAxOptCtrl)

Note: The number 4 in begin_proppageids indicates the number of attribute pages. When you add an attribute page, you must update it in time.

PS: if the control's inherent property page cannot be accessed, it may be because the mfc dll (mfcxx. dll) is not correctly registered by the current operating system.


2. Add a custom property page

First, add a new property page resource to your project.

  1. Open resource view
  2. Right-click resource view and choose add resource from the shortcut menu.
  3. Expand the dialog node and select idd_ole_proppage_small.
  4. Click new to add resources to your project.
  5. Go to the new property page
  6. Change its ID
  7. Click Save on the toolbar.

Next, create a class that is associated with this property page. The method is skipped. Note that the base class is "colepropertypage. Assume that the class name is cyourownppage.

To allow the control user to access the newly added property page, you also need to add the corresponding statement in the initialization code of the ID array of the control property page, such:

BEGIN_PROPPAGEIDS(CMyAxUICtrl, 2)   PROPPAGEID(CMyAxUIPropPage::guid)    PROPPAGEID(CYourOwnPPage::guid)END_PROPPAGEIDS(CMyAxUICtrl)

Note: Increase the count in the in_proppageids macro. Of course, do not forget to include the header file.

Finally, add a new string resource to the attribute page. Here, we need two string resources. The adding method is omitted and the two resource IDs are ids_sample_addpage and ids_sample_addppg_caption. Modify the second code in the cyourownppage class.

1,

BOOL CAddtlPropPage::CAddtlPropPageFactory::UpdateRegistry(BOOL bRegister){   if (bRegister)      return AfxOleRegisterPropertyPageClass(AfxGetInstanceHandle(),         m_clsid, IDS_SAMPLE_ADDPAGE);   else       return AfxOleUnregisterClass(m_clsid, NULL);}

2,

CAddtlPropPage::CAddtlPropPage() :   COlePropertyPage(IDD, IDS_SAMPLE_ADDPPG_CAPTION){}


Now, the property page is added

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.