Click here to Skip to main content
15,889,877 members
Articles / Desktop Programming / MFC
Article

Property list ActiveX control

Rate me:
Please Sign up or sign in to vote.
3.88/5 (23 votes)
4 Nov 20043 min read 190.2K   7K   58   61
Property list similar to VB.NET, implemented as ActiveX control.

Sample Image - propList.gif

Important

The article is updated! See below for the changes!

Introduction

This property list control is similar to other property lists available, with two main differences:

  1. It's very easy to implement.
  2. It's implemented as an ActiveX control, so it's suitable for C++, C#, and VB as one. Also, it can be placed on an HTML page or any other container that supports ActiveX and script.

Reference

Properties
  • BorderStyle As BorderStyle

    The border style of the control.

    BorderStyle enum:

    • BorderNone = 0 - No border
    • BorderRaized = 1 - EDGE_RAISED
    • BorderSunken = 2 - EDGE_SUNKEN
    • BorderFlat = 3 - BDR_RAISEDOUTER|BDR_RAISEDINNER, BF_FLAT
    • BorderStatic = 4 - BDR_SUNKENINNER
  • Precision As Short

    Overall precision of double values (* not used at the moment).

Methods
  • Clear()

    Clears all the properties from control.

  • AddProperty(BSTR Category, BSTR Caption, VARIANT Value, BSTR Description, buttonType ButtonType,VARIANT_BOOL IsEnabled)

    Adds new property to the control.

    • Category - the category of the property.
    • Caption - the caption (the string name of the property).
    • Value - the property value (String, Short, Long, String array, DateTime, Picture etc...).
    • Description - the text to display in the description window.
    • ButtonType - the button type of the property (* applicable to edit controls, and DateTime control).
    • IsEnabled - is the property enabled.

    ButtonType enum:

    • ButtonNone = 0 - no button
    • ButtonElipsis = 1 - ellipsis button (three dots), edit control created.
    • ButtonPick = 2 - pick button (arrow with x), edit control created.
    • ButtonOpen = 3 - button opens a file open dialog, edit control created.
    • ButtonLink = 4 - button opens the Explorer, edit control created.
    • ButtonColor = 5 - button opens pick color dialog, color control created.
    • ButtonMail = 6 - button opens new mail message, edit control created.
    • ButtonLongDate = 7 - displays a date in long format, DateTime control created.
    • ButtonShortDate = 8 - displays a date in short format, DateTime control created.
    • ButtonTime = 9 - displays a time, DateTime control created.
  • SetValue(BSTR PropertyName, VARIANT Value)

    Sets a value for single property.

    • PropertyName - the name of the property to set the value for.
    • Value - the value to set.
Events
  • PropertyChanged(BSTR PropertyName, VARIANT NewValue)

    Fired on property change.

    • PropertyName - the name of the property that changed.
    • NewValue - the new value.
  • ButtonClicked(BSTR PropertyName, short ButtonType, VARIANT* Value)

    Fired on button click allowing you to perform some custom action for the button, and set the value to a new one as the result of performed actions.

    • PropertyName - the name of the property whose button was clicked.
    • ButtonType - the type of the button.
    • Value - passed ByRef (as pointer) allowing you to set a new value on function return.

* Note that some of the controls have a default action for button click, as the color button, linkbutton, mail button etc...

History

Update - 04/11/2004

New Properties
  • ShowDescription As Boolean

    Controls display of the description (True/False).

New Methods
  • CloseAll()

    Closes all the categories (useful if you'd like to start the list when all the categories are closed. You can fill the list then call CloseAll() to close the categories).

New button types
  • ButtonMultyText = 10 - Creates a text window five rows high for multiple lines text.
  • ButtonButton = 11 - Creates a button which occupies the entire row.
  • ButtonFunction = 12 - Creates a property whose value is calculated from the provided function which may be based on other properties. For example:

    You have a property named Diameter and its value is 10. You add a function type property named area, click on its button, the "Enter function" dialog appears where you write - 3.14 * ([Diameter]/2)^2. After you close the dialog, the value displayed in the property would be: 78.5. If you now change the Diameter to 4, the Area property will automatically update to 12.56.

  • ButtonPicture = -1 - The passed string is a path to an image file (you can also pass images as IDispatch interface).

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
Software Developer (Senior) RDV Systems
Israel Israel
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralMy vote of 5 Pin
duke.liu7-Sep-11 23:15
duke.liu7-Sep-11 23:15 
GeneralMy vote of 5 Pin
mychina14-Mar-11 19:09
mychina14-Mar-11 19:09 
GeneralDear sir,I have a question. Pin
king5524047019-Feb-11 22:44
king5524047019-Feb-11 22:44 
GeneralRe: Dear sir,I have a question. Pin
king5524047020-Feb-11 0:07
king5524047020-Feb-11 0:07 
GeneralRe: Dear sir,I have a question. Pin
Alex Hazanov20-Feb-11 1:15
Alex Hazanov20-Feb-11 1:15 
GeneralMy vote of 5 Pin
123456anurag27-Oct-10 20:53
123456anurag27-Oct-10 20:53 
Generalusing the arrow keys to move thru list Pin
Steve P13-Jun-08 13:01
Steve P13-Jun-08 13:01 
GeneralUsing SetValue for combobox Pin
dynal12-Jul-07 5:06
dynal12-Jul-07 5:06 
GeneralRe: Using SetValue for combobox Pin
camalia7-Aug-07 14:18
camalia7-Aug-07 14:18 
GeneralReally nice, some bugs/problems Pin
Paul Kobold19-Apr-07 3:47
Paul Kobold19-Apr-07 3:47 
First bugs which i encountered so far:

In the CEditItem::OnKillFocus procedure there is no check for bChange to call Apply, so Apply ist called even if u press Escape and KillFocus is called.

For people that have problems (i.e. the german üäöß) with the displayed Font, the main font (created in CMyList::CMyList()) uses the HEBREW_CHARSET, change that to the charset u need (in normal case ANSI_CHARSET should do it.


I have a special problem and dont know if it's me or better my App, the VS 2003 Compiler, or a "Bug" in the Control.
I use c++ and mfc and create the control at runtime which is no problem.
For that I created a wrapper class derived from CWnd(similar to the one in the sample project), in my window (no dialog), where the control should be placed, i have a member variable of that class, the Eventprocedures and create with CreateControl the Control.
No problems so far, the control is created, it fires the Events correctly etc. BUT, the Edit Controls dont get the VK_ESCAPE and VK_RETURN. All other keys are send to the Control.
My problem is now who takes the message and kills it.
Hierarchy is -> Mainfrm -> Propertybar(customwnd) -> Propertysheet(customwnd) -> Wrapperclass with Control if it helps.
I tried for hours and didnt get another solution as described down or found the one who kills the message and send it not to the Control.
My Solution was in the Wrapperclass:PretranslateMessage() i get the VK_ESCAPE & VK_RETURN message with the correct handle of the Control. So at this point I send it directly to the Control.

What i really dont understand is that in the Control i dont get ANY PretranslateMessage Calls in any of the windows/classes, is that COM related or why isnt it fired. Where can i get the Message before it's translated/dispatched ?!
Next problem is, that if i create it at runtime in my app if i press the Escapekey in a Multilineeditcontrol, all items,but the description, in the Control are killed, and a heavy exception is fired as soon as the Control losts the Focus o_O. The Returnkey doesnt do anything.
That happens with or without my Pretranslate"hack".
It seems like the behaviour of OnOK and OnCancel, the question is where.
So i think there is anything in the Control who dispatches or translate the Enter and Escape Key to the wrong place, but because no pretranslate is called i dont know where to get in and search for it.

The strange is, that the Control in an VisualBasic (6.0) app hasn't that behaviour and functions so as u expect it. Can anyone help ?
GeneralRe: Really nice, some bugs/problems Pin
Paul Kobold19-Apr-07 4:41
Paul Kobold19-Apr-07 4:41 
GeneralGreat, but .... Pin
Bui Tan Duoc6-Feb-07 14:49
professionalBui Tan Duoc6-Feb-07 14:49 
QuestionHow to add new column Pin
jeando200317-Oct-06 15:04
jeando200317-Oct-06 15:04 
Questionhow to set value to Property whose type is ComboBox Pin
Dnyaneshwar Kotwal10-Aug-06 19:16
professionalDnyaneshwar Kotwal10-Aug-06 19:16 
AnswerRe: how to set value to Property whose type is ComboBox Pin
Alex Hazanov18-Aug-06 11:10
Alex Hazanov18-Aug-06 11:10 
QuestionHow can I set value of SAFEARRAY type Pin
Nabam11-Jul-06 23:27
Nabam11-Jul-06 23:27 
GeneralActiveX contol properties Pin
Alton Williams10-May-06 4:44
Alton Williams10-May-06 4:44 
GeneralRe: ActiveX contol properties Pin
Alex Hazanov22-May-06 2:02
Alex Hazanov22-May-06 2:02 
GeneralMy question answered: Pin
Alton Williams30-May-06 4:33
Alton Williams30-May-06 4:33 
Generalbug : coud not redraw window valid Pin
sillyemperor22-Jan-06 19:20
sillyemperor22-Jan-06 19:20 
QuestionJavascript combobox problems Pin
CoMiKe14-Dec-05 2:51
CoMiKe14-Dec-05 2:51 
AnswerRe: Javascript combobox problems Pin
Alex Hazanov14-Dec-05 4:57
Alex Hazanov14-Dec-05 4:57 
GeneralRe: Javascript combobox problems Pin
CoMiKe14-Dec-05 13:16
CoMiKe14-Dec-05 13:16 
GeneralRe: Javascript combobox problems Pin
CoMiKe15-Dec-05 1:54
CoMiKe15-Dec-05 1:54 
GeneralWell Done Pin
valladis16-Aug-05 3:14
valladis16-Aug-05 3:14 

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.