Microsoft Chat Server Development Guide

Add support for ISpecifyPropertyPages

The ISpecifyPropertyPages interface indicates that an object supports property pages. Each property page implements the IPropertyPage interface.

If you have created a new property page component in Visual Basic, the component will already support the necessary interfaces. The following steps are required for extensions (or property page components) that are written in C++ using ATL 5.0.

  1. In your extension's header file, add a class inheritance from ISpecifyPropertyPagesImpl template. For example,
    class ATL_NO_VTABLE CMessageFilter : 
        public CComObjectRootEx<CComSingleThreadModel>,
        public CComCoClass<CMessageFilter, &CLSID_MessageFilter>,
        public IDispatchImpl<IChatMsgFilter, &IID_IChatMsgFilter, &LIBID_MSGFILTERLib>,
        public IDispatchImpl<IChatExtensionCallBack, &IID_IChatExtensionCallBack, &LIBID_CHATSVCLib>,
        public IDispatchImpl<IChatServerCallBack, &IID_IChatServerCallBack, &LIBID_CHATSVCLib>,
    
        public ISpecifyPropertyPagesImpl<CMessageFilter>
    {
    public:
    .
    .
    .
    
  2. Add a COM_INTERFACE_ENTRY for the ISpecifyPropertyPages interface. For example,
    BEGIN_COM_MAP(CMessageFilter)
        COM_INTERFACE_ENTRY2(IDispatch, IChatMsgFilter)    
        COM_INTERFACE_ENTRY(IChatMsgFilter)
        COM_INTERFACE_ENTRY(IChatExtensionCallBack)
        COM_INTERFACE_ENTRY(IChatServerCallBack)
    
        COM_INTERFACE_ENTRY_IMPL(ISpecifyPropertyPages)        
    END_COM_MAP()
    
  3. Add the declaration for the GetPages method of the ISpecifyPropertyPages interface to your extension. For example,
    public:
        HRESULT ISpecifyPropertyPages_GetPages(CAUUID* pPages, ATL_PROPMAP_ENTRY* pMap);
    
  4. Implement the GetPages method using the following code:
    HRESULT CMessageFilter::ISpecifyPropertyPages_GetPages(CAUUID* pPages, ATL_PROPMAP_ENTRY* pMap)
    {
        int nCnt = 0;
    
        // Get count of unique pages
        for(int i = 0; pMap[i].pclsidPropPage != NULL; i++)
        {
            if (!InlineIsEqualGUID(*pMap[i].pclsidPropPage, CLSID_NULL))
                nCnt++;
        }
    
        pPages->pElems = NULL;
        pPages->pElems = (GUID*) CoTaskMemAlloc(sizeof(CLSID)*nCnt);
        if (pPages->pElems == NULL)
            return E_OUTOFMEMORY;
    
        nCnt = 0;
        for(i = 0; pMap[i].pclsidPropPage != NULL; i++) {
            if (!InlineIsEqualGUID(*pMap[i].pclsidPropPage, CLSID_NULL)) {
                BOOL bMatch = FALSE;
                for (int j=0;j<nCnt;j++) {
                    if (InlineIsEqualGUID(*(pMap[i].pclsidPropPage), pPages->pElems[j])) {
                        bMatch = TRUE;
                        break;
                    }
                }
                if (!bMatch)
                    pPages->pElems[nCnt++] = *pMap[i].pclsidPropPage;
            }
        }
        pPages->cElems = nCnt;
        return S_OK;
    }

Adding property pages in C++

  1. From the Insert menu, select New ATL Object.
  2. Select "Controls" in the left-hand pane and "Property Page" from the right. Click Next.
  3. Type the name of your property page component in the "Short Name" edit box. You should also change the title and help strings of your property page from the Strings tab of the ATL Object Wizard Properties dialog box. Click OK.
  4. Add a PROPERTY_MAP to your component's header file. This map is used by GetPages to return the array of property pages supported by your extension. Add an entry for each property page you have created. For example,
    BEGIN_PROPERTY_MAP(CMessageFilter)
        PROP_PAGE(CLSID_MsgFilterPP)
    END_PROPERTY_MAP()
    
  5. Implement the logic of your property page. Refer to the MsgFilter sample for more information.

© 1998 Microsoft Corporation. All rights reserved.