How to customize OLE property frame window with ATL and WTL

Window API provides useful functions OleCreatePropertyFrame and OleCreatePropertyFrameIndirect, which allow easily to pop up object’s property pages, OLE property pages. The frame, however, is not customizable, does not even allows centering relative to parent’s window. COlePropertyFrameDialogT template class is to be a solution for this problem.

Additionally the template offers useful methods to discover available property pages from object’s ISpecifyPropertyPages interface, if available. With multiple objects you have a choice to show union of individual object’s pages, or intersection of the pages (that is show only pages supported by all provided objects).

31-Image001.png

Code excerpt:

CMyOlePropertyFrameDialog Dialog;
Dialog.SetObject(pSampleObjectUnknown);
// NOTE: This instructs dialog to query for proeprty pages from assigned object(s)
Dialog.SetObjectPages();
const INT_PTR nDialogResult = Dialog.DoModal(m_hWnd);

The sample project/application provides reusable COlePropertyFrameDialogT template class, customized  CMyOlePropertyFrameDialog class to show frame centered by owner (through handling WM_INITDIALOG message using WTL’s MSG_WM_INITDIALOG macro) and a sample COM object CSampleObject with associated Color property page from stock property pages (implemented by ATL/MFC).

Visual C++.NET 2005 source code can be downloaded here, compiled binary – here.

Leave a Reply