Click here to Skip to main content
Click here to Skip to main content

Template class for 'Property Browser'- like property pages for ATL ActiveX Controls

By , 26 Nov 1999
 

Sample Image

Developing ActiveX Controls I always was unhappy to spend a fair amount of time to monotonous GUI work designing and implementing a property pages. Eventually I wrote this class that works in most cases as a universal property page for any ATL-based ActiveX Control. The prototype for this class is property browser window known for to any Visual Basic developers.

How it works:

Generally, this class uses IPropertyPage::SetObjects and queries the control's IDispatch::GetTypeInfo to enumerate properties. Currently, this template class can handle the following kinds of properties: Simple types such as long, short, text(BSTR), ect. Font (IFontDisp) OLE_COLOR Picture (IPictureDisp) enums boolean (VARIANT_BOOL)

Current implementation don't display properties that has [hidden] or [nonbrowsable] attributes as well as indexed properties and properties of custom types (IFoo* or similar). The control's default interface should be dual and derived from IDispatch. If you use enumerated properties, the control must support IPerPropertyBrowsing::GetPredefinedStrings and IPerPropertyBrowsing::GetPredefinedValue (look at the demo project for a sample) The main template class CPropertyBrowserPage is derived from both IPropertyPageImpl and CDialogImpl and uses some other helper classes that is briefly described below:

  • CPropBrowseWnd class is a owner-drawn listbox that displays properties grid and handles property selections, start/stop editing, ect. It is a main GUI window and CPropertyBrowserPage creates it in OnInitDialog.
  • CPBProperty is a simple class for storage properties attributes like name, type, current value and "dirty" status.
  • CPBPropertyHolder helper class is just a very simple container (array) of CPBProperty objects.
  • CPBColorPicker class is popup color picker window that allow user to choose color either from palette or from system's colors set.
  • CPBDropListBox class works together with in-place edit window to resemble combo-box like interface
  • PBDib class generally wasn't developed by me, this class encapsulates DIB manipulations API

How to use:

  1. Copy following files to your project's directory:

    • PropertyBrowserPage.h
    • PropertyBrowserPage.cpp
    • PBDib.h
    • PBDib.cpp
    and add *.cpp files to the project.
  2. Select "New ATL Object" from the Insert menu. Select "Property Page" and fill all fields Wizard requires. (For example, assume you choose "CDemoCtrlPage" as the name of your page's class)
  3. Go to CDemoCtrlPage class declaration and modify base classes list as following

    class ATL_NO_VTABLE CDemoCtrlPage :
    public CComObjectRootEx<CComSingleThreadModel>,
    public CComCoClass<CDemoCtrlPage, &CLSID_DemoCtrlPage>,
    //	public IPropertyPageImpl, <--- this lines should be removed
    //	public CDialogImpl 
    /* next line should be added*/
    public CPropertyBrowserPage<CDemoCtrlPage>
    next, change message map chain macro as following:
    BEGIN_MSG_MAP(CDemoCtrlPage)
    /* CHAIN_MSG_MAP(IPropertyPageImpl<CDemoCtrlPage>) <--- this line should be removed*/ 
    CHAIN_MSG_MAP(CPropertyBrowserPage<CDemoCtrlPage>)/*<--- this line should be added*/
    END_MSG_MAP() 
    
    and remove Wizard-generated CDemoCtrlPage::Apply() method and finaly don't forget to include PropertyBrowserPage.h
  4. Add following macro in your control's class property map
    	PROP_PAGE(CLSID_DemoCtrlPage)
    
  5. Go to Wizard-generated page's dialog template and remove all child controls.
  6. Please note that this class uses some C RTL code that makes _ATL_MIN_CRT directive impossible so you have to remove it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Vladimir Shcherbakov
Web Developer
United States United States
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionDoes this work in windowless controls?memberArunKumar Yalamarthy5 Jul '07 - 3:23 
Does this work in windowless controls?
GeneralGreat examplemembersunnywu522 Jun '07 - 11:52 
I got a big benefit from it to my Generic Property Window docked a side of Main Window
Thanks guy!!

QuestionHow to call Activex Dll in MFC Dialog application?memberAshwin kumar Gurujala5 Dec '05 - 18:30 
I want to attach ActiveX DLL "Property Browser" to existing MFC Dialog Based Application. How can i use the DLL ? I have registered the DLL but it is not visible in the Registered ActiveX Controls of MFC. How should i use it?
 
Can anyone help this out !
AnswerRe: How to call Activex Dll in MFC Dialog application?memberRajam Kiran10 Nov '06 - 2:03 
Smile | :) Register the ActiveX Control first.
While compling it shows the register information in output window.otherwise goto Tools and select "Register Control Option" and check it man
QuestionHow can i use it with a ATL com without any property pagememberInam8 Feb '04 - 20:06 
I have a ATL com component in which i have not implemented property pages. Is this possible to use that browser with that .Please guide me a little.
Thanx in advance
Regards
minamkhan
 
Inam
Generalgood but....memberTom Mason3 Aug '01 - 4:32 
Like the property page class, but it has a small bug. On apply it puts all the property values regardless of whether they are dirty or not. This is not ideal when you have LOTS of properties with much work behind them.
 
cheers anyway, you've saved me a lot of grief.
GeneralExcellent!memberRafael Gómez Blanes31 May '01 - 6:17 
You have saved me many work debuggin my application with your sample. Thanks guy!!
GeneralProperty BrowsersussDan Phalen18 Aug '00 - 16:35 
This tool saved me weeks of drudge work. My ATL component manages 15 ATL subcomponents that I coded two years ago without property pages. To make the components work in web apps, I needed the property pages. Guess what? Your browser came to the rescue. Many thanks, Vladimir, for an excellent job.
 
Da

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web02 | 2.6.130523.1 | Last Updated 27 Nov 1999
Article Copyright 1999 by Vladimir Shcherbakov
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid