Click here to Skip to main content
15,867,488 members
Articles / Desktop Programming / ATL
Article

Setting Properties with OLE Automation

Rate me:
Please Sign up or sign in to vote.
5.00/5 (4 votes)
5 Aug 2000 101.3K   2.3K   42   8
Describes an ActiveX Control to use OLE Automation to set an object's properties.
  • Download demo project - 113 Kb
  • Download source files - 114 Kb
  • Sample Image - PropertySetCtl.jpg

    Table of Contents.

    1. Introduction
    2. How it works
    3. Control interface
    4. Source interface
    5. User interface
    6. Environment
    7. Acknowledgement, References
    8. Some words about VB demo

    Introduction

    kPropertySet.kObserver - This ActiveX control provides a way for presenting and editing of the set of properties (Visual Basic IDE - like property browser).

    The main features are:

    1. Editing a set of properties through the IDispatch interface.
    2. Works with IPerPropertyBrowsing and ICategorizeProperties interfaces
    3. Supports any type of property compatible with OLE automation
    4. Supports user-defined types
    5. Sorting for alphabet and categories
    6. Flexible customization
    7. Small size: 73.5 KB in release min size configuration

    How it works

    After receiving the pointer from the IDispatch interface, the control explores the type library. For each property with attribute "propget" there is an object implementing the logic of visualization, data exchange and data validation. The properties with attributes "hidden", "nonbrowsable", and "restricted" are skipped.


    Control interface

    The following is a description of the kObserver interface:

    Property Dispatch:
    External dispatch interface.

    Property Font:
    Current font.

    Property BackColor:
    Back color of list view window.

    Property ForeColor:
    Foreground color used for display text.

    Property GridColor:
    Color used for display grid.

    Property HighliteBackColor:
    Color used for display selected item.

    Property HighliteForeColor:
    Color used for display text of selected item.

    Property EditBackColor:
    Background color used for display edit window.

    Property EditForeColor:
    Foreground color used for display text in edit window.

    Property SignColor:
    The sign color.

    Property EnableContextMenu:
    Must be false if show of the context menu is unnecessary.

    Property Categorized:
    Sort mode, true if sorting by categories.

    Property LineSpacing:
    Additional spacing between rows can be negative.

    Property exStyleEdit:
    Extended window style of edit window.

    Property SelectName:
    Name of active property.

    Property SelectDesc:
    Description of active property.

    Property SelectValue:
    Value of active property.

    Property SelectDispid:
    DISPID of active property.


    Source interface

    Method OnChangeSelect:
    Occurs when user changes the active property.


    User interface

    Keyboard keys:

    • F5: refresh
    • F2, tab: edit property (if possible)
    • Space: simulate right button click

    Context Menu:

    • Alphabetic \ Categorized: select sort mode
    • Restore \ Customize Self: edit self property or external
    • Refresh: repaint and reload property value

    Environment

    This component was created with VC 6.0. (SP3) and ATL. It has been tested on Windows 2000 and Windows 98. Requires: Windows 98, Windows NT 4.0, Windows 2000, and Interned Explorer 4.


    Acknowledgement, References

    The following source code was used in writing this ActiveX control:

    Thanks them once more.

    Some words about VB demo

    For persisting \ restoreing the property in VB runtime I write the kPersistMngs.kStorageMng component. It's a simple wrapper to work with compound files in VB.

    History

    • 6 Aug 2000 - updated to version 1.2 and fixes bugs detected by Robert Rolls

    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


    Written By
    Web Developer
    Russian Federation Russian Federation
    I am freelance programmer. About 3 years of experience in C++ and I would rather use ATL, STL, WTL but not MFC Smile | :) . Main backgrounds are Win32 API, COM and Networking. Now I am interested about AI (Neural Network, Fuzzy Logic and GA). Currently based in Vladivostok, Russia.

    Comments and Discussions

     
    Generaluse with Visual C++ resource editor Pin
    tangi maury7-Apr-04 0:25
    tangi maury7-Apr-04 0:25 
    GeneralQuite Impressing ! Pin
    Braulio Dez30-May-02 0:24
    Braulio Dez30-May-02 0:24 
    GeneralYou forgot cVars,,, Pin
    4-Jan-02 21:30
    suss4-Jan-02 21:30 
    Generalmultiple IDispatch Pin
    cheesesarnie19-Dec-01 4:57
    cheesesarnie19-Dec-01 4:57 
    GeneralRe: multiple IDispatch Pin
    Konstantin Boukreev19-Dec-01 15:12
    Konstantin Boukreev19-Dec-01 15:12 
    Generalregit Pin
    cheesesarnie19-Dec-01 0:39
    cheesesarnie19-Dec-01 0:39 
    GeneralThanx ! Pin
    Ivan Tsygulev9-Oct-01 5:29
    Ivan Tsygulev9-Oct-01 5:29 
    GeneralSlight Problems. Pin
    JoeBloggs3-Aug-00 22:23
    JoeBloggs3-Aug-00 22:23 
    Try browsing Microsoft's Masked Edit Control ;o( Also I'd suggest not browsing indexed properties - there meaningless without being able to set the index before the value. The Bullseys ATL ActiveX control is a prime example

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

    Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.