ATL and Developer Tools

[Previous] [Next]

Executing the properties verb isn't the only way for an ActiveX control to show its property pages. As we mentioned before, folks who write developer tools (tools such as Visual Basic and Visual C++) might want programmatic access to a control's property pages. For example, imagine working on a dialog box containing an ActiveX control. When you right-click on the control to view the properties, you get a dialog frame produced by Visual C++ (as opposed to OleCreatePropertyFrame).

Visual C++ uses the control's ISpecifyPropertyPages interface, shown here, to get the list of GUIDs:

 interface ISpecifyPropertyPages : public IUnknown {     HRESULT GetPages(CAUUID *pPages); }; typedef struct tagCAUUID  {      ULONG     cElems;      GUID FAR* pElems;  } CAUUID; 

ATL implements this interface by cycling through the list of GUIDs (produced by the property map macros) and returning them within the CAUUID structure. Environments such as Visual C++ then use each GUID in a call to CoCreateInstance to create new property pages.

Pushing the Apply Button

The last interesting part of ATL's property pages to examine is how to implement the Apply method. Once it has produced the set of pages (by using OleCreateFrame or some other means), the client code can ask the property page to apply new properties. Remember that the ActiveX control and the property page are separate COM objects, so they need to communicate via interfaces.

When you create a property page using the ATL Object Wizard, ATL overrides the Apply function from IPropertyPage. The ActiveX control has the necessary interfaces—they were passed into the property page early in the game via a call to IPropertyPage::SetObjects. Most property pages respond to the Apply function by setting the state of the ActiveX control through the interface provided.



Inside Atl
Inside ATL (Programming Languages/C)
ISBN: 1572318589
EAN: 2147483647
Year: 1998
Pages: 127

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net