Undocumented Corner

by George Shepherd and Scot Wingo



Listing One

interface IPropertyPage : public IUnknown {

   HRESULT SetPageSite(IPropertyPageSite *pPageSite) = 0;

   HRESULT Activate(HWND hWndParent, LPCRECT pRect, BOOL bModal) = 0;

   HRESULT Deactivate( void) = 0;

   HRESULT GetPageInfo(PROPPAGEINFO *pPageInfo) = 0;

   HRESULT SetObjects(ULONG cObjects, IUnknown **ppUnk) = 0;

   HRESULT Show(UINT nCmdShow) = 0;

   HRESULT Move(LPCRECT pRect) = 0;

   HRESULT IsPageDirty( void) = 0;

   HRESULT Apply( void) = 0;

   HRESULT Help(LPCOLESTR pszHelpDir) = 0;

   HRESULT TranslateAccelerator(MSG *pMsg) = 0;

};



Listing Two

struct ATL_PROPMAP_ENTRY

{

   LPCOLESTR szDesc;

   DISPID dispid;

   const CLSID* pclsidPropPage;

   const IID* piidDispatch;

};

#define BEGIN_PROPERTY_MAP(theClass) \

  typedef _ATL_PROP_NOTIFY_EVENT_CLASS __ATL_PROP_NOTIFY_EVENT_CLASS; \

  static ATL_PROPMAP_ENTRY* GetPropertyMap()\

  {\

    static ATL_PROPMAP_ENTRY pPropMap[] = \

    {

#define PROP_PAGE(clsid) \

    {NULL, NULL, &clsid, &IID_NULL},

#define PROP_ENTRY(szDesc, dispid, clsid) \

    {OLESTR(szDesc), dispid, &clsid, &IID_IDispatch},

#define PROP_ENTRY_EX(szDesc, dispid, clsid, iidDispatch) \

    {OLESTR(szDesc), dispid, &clsid, &iidDispatch},

#define END_PROPERTY_MAP() \

      {NULL, 0, NULL, &IID_NULL} \

    }; \

    return pPropMap; \

  }



Listing Three

class ATL_NO_VTABLE CTestCtl : 

   ... {

   ...



BEGIN_PROPERTY_MAP(CTestCtl)

    PROP_ENTRY("Caption goes here...", 2, 

                CLSID_MainPropPage)

    PROP_ENTRY_EX("Caption goes here...", 3,

                  CLSID_SecondPropPage, 

                  DIID_SecondDualInterface)

    PROP_PAGE(CLSID_StockColorPage)

END_PROPERTY_MAP()

};



Listing Four

interface ISpecifyPropertyPages : public IUnknown {

   HRESULT GetPages(CAUUID *pPages);

};

typedef struct tagCAUUID 

{ 

    ULONG     cElems; 

    GUID FAR* pElems; 

} CAUUID;





2



