Partilhar via


Specifying Property Pages

When you create an ActiveX control, you will often want to associate it with property pages that can be used to set the properties of your control. Control containers use the ISpecifyPropertyPages interface to find out which property pages can be used to set your control's properties. You will need to implement this interface on your control.

To implement ISpecifyPropertyPages using ATL, take the following steps:

  1. Derive your class from ISpecifyPropertyPagesImpl.

  2. Add an entry for ISpecifyPropertyPages to your class's COM map.

  3. Add a PROP_PAGE entry to the property map for each page associated with your control.

Observação

When generating a standard control using the ATL Control Wizard, you will only have to add the PROP_PAGE entries to the property map. The wizard generates the necessary code for the other steps.

Well-behaved containers will display the specified property pages in the same order as the PROP_PAGE entries in the property map. Generally, you should put standard property page entries after the entries for your custom pages in the property map, so that users see the pages specific to your control first.

Example

The following class for a calendar control uses the ISpecifyPropertyPages interface to tell containers that its properties can be set using a custom date page and the stock color page.

class ATL_NO_VTABLE CMyCtrl :
   OtherInterfaces
   public ISpecifyPropertyPagesImpl<CMyCtrl>
{
public:

BEGIN_COM_MAP(CMyCtrl)
   OtherComMapEntries
   COM_INTERFACE_ENTRY(ISpecifyPropertyPages)
END_COM_MAP()

BEGIN_PROP_MAP(CMyCtrl)
   OtherPropMapEntries
   PROP_PAGE(CLSID_DatePage)
   PROP_PAGE(CLSID_StockColorPage)
END_PROP_MAP()

   // Remainder of class declaration omitted.

See Also

Concepts

ATL COM Property Pages

Other Resources

ATLPages Sample