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

Property list ActiveX control

By , 4 Nov 2004
 

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

About the Author

Alex Hazanov
Software Developer (Senior) RDV Systems
Israel Israel
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   
GeneralMy vote of 5memberduke.liu7 Sep '11 - 23:15 
useful for me
GeneralMy vote of 5membermychina14 Mar '11 - 19:09 
great
GeneralDear sir,I have a question.memberking5524047019 Feb '11 - 22:44 
Hello Sir:
I am a student in China.
I use your proplist.ocx in my program, and I found it does not support Chinese. All the words written in Chinese is in disorder.
 
So, is there any method to solve this problem?
 
Thank you!
GeneralRe: Dear sir,I have a question.memberking5524047020 Feb '11 - 0:07 
It works, now. Thank you. It is a good control which brings much convenience.
The method you provide in previous issue about Spanish support is right.
 
I enconter 38 errors as well.
And the steps to solve this problem are listed as following.
 
1. Download the source code of Proplist.ocx
2. Re-compile it, then 38 errors will be found.
3. Select Project--->settings--->c/c++--->category--->preprocessor
At the blank of Preprocessor definitions, remove _UNICODE.
4. Find the construction function of CMylist, replace the original charset with proper charset.
 
That's all.
 
Thanks, again!
GeneralRe: Dear sir,I have a question.memberAlex Hazanov20 Feb '11 - 1:15 
Glad you sorted that out...
 
The control is a bit out dated to say the least and I have no intention of updating since .NET provides very nice PropertyGrid.
So any contribution that might help all the c++ and ActiveX guys is welcome...

Creative minds - create creative creations!

GeneralMy vote of 5member123456anurag27 Oct '10 - 20:53 
i am software engineer in Nozomi Infotech facing problem in using CList control in ActiveX so i get direction to search by your artical sir Thanks.
my id is anurag221188@gmail.com
Generalusing the arrow keys to move thru listmemberSteve P13 Jun '08 - 13:01 
Very nice!
Has anyone come up with a way to use the arrow keys instead of just the mouse to move thru the list. I haven't been able to find the entry in the source to modify the code for this behavior. I'm using VC++ 6.0
GeneralUsing SetValue for comboboxmemberdynal12 Jul '07 - 5:06 
Hi There,
 
Is there a way to use SetValue to change the state of a combobox. I would like to change the property settings when different files are loaded. I know it is possible at the start using the AddProperty function, just not sure how use setValue in this instance.
 
Thanks
GeneralRe: Using SetValue for comboboxmembercamalia7 Aug '07 - 14:18 
You must rebuild the activex PropList object after making some changes.
1. open class CComboItem in activex object`s project
2. replace body of SetValue(..) with
 
if (CListItem::SetValue(Value) == FALSE)
return FALSE;
 
if (IsWindow(m_hWnd))
SetCurSel(Value.intVal);
 
return TRUE;
 
Good luck!
GeneralReally nice, some bugs/problemsmemberPartyPaul19 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/problemsmemberPartyPaul19 Apr '07 - 4:41 
For the multylineedit some workaround, but no solution for the problem itself:
 
in CPropListCtrl::CPropListCtrl()
the fonts arent created with a proper Charset, with a Charset set to Ansi the problem with the return was solved, it now insert a newline. (Other method would be create the Multilinecontrol with ES_OEMCONVERT)
 
In the OnKeyDown Event of the CMultylineEdit you'll get the Escape key(and all other key events), if u return there and dont call the baseclass implementation, nothing will happen (and that really confuses me now, so if the Escape message is given to the baseclass all list items disappear ?!? wtf, i really dont understand that), so for the Escape button i return without calling __super::OnKeyDown(...);
GeneralGreat, but ....memberBui Tan Duoc6 Feb '07 - 14:49 
That's great control. But I have some problem !
- I don't know how to change font at runtime
- How can I format date (dd/mm/yyyy or mm/dd/yyyy,..)
- Can I use spin to change date instead showing calendar to choose
Thanks very much .
QuestionHow to add new columnmemberjeando200317 Oct '06 - 15:04 
It seems like it can only have two colunm, so how can I add new column.
 
I want to have something like that like
 
FirstName LastName IDNumber Date
========== ======== ======== =====
Questionhow to set value to Property whose type is ComboBoxmemberDnyaneshwar Kotwal10 Aug '06 - 19:16 
Smile | :) First of Thanks for creating such a useful tool.
Gr8 work u have done.
But I have one problem using it,if possible then plz answer as quick as possible.
 
Problem is : how to set value to Property whose type is ComboBox
 
By default I have the 1st value (etc "Unit1") in SAFEARRAY. But what can I do if I want to get for example "Unit3" during the initialization. How can I set SAFEARRAY value properly?
Please tell me about it?
 

 
Search: Articles Authors
Help! Articles Message Boards StoreFront Lounge



 
Premium Sponsor
 

All Topics MFC / C++ C# ASP.NET .NET
Site MapAdd To FavoritesCodeProject StuffWho's WhoTell a friendIndustry ContactsASP.NETManaged C++.NETSOAP and XMLVB.NETC++ Web Services.NET Compact FrameworkCross PlatformCombo & ListboxesMenus & ToolbarsC# ControlsC# ProgrammingMultimediaC# DatabaseC# WebServicesButton Co

AnswerRe: how to set value to Property whose type is ComboBoxmemberAlex Hazanov18 Aug '06 - 11:10 
I am sorry for answering only now, I havent been reading my e-mails for a while...
If I understood tour question correctly you are asking how to set the selected item in the combo box at the start... well if I am remember correctly , you set the buttontype parameter to integer that is the number of the selected item : ie:
AddProperty "Some Category", "Caption", stringArray, "Description", 5, TRUE
 
Item number 6 will be selected (items start from 0)
 

Creative minds - create creative creations!

QuestionHow can I set value of SAFEARRAY typememberNabam11 Jul '06 - 23:27 
I'm using this ActiveX in VC6 environment and my code looks as follows

 
resourceText.LoadString(IDS_ADMINTASK_USERLEVEL);
 
status = NetWkstaUserEnum(NULL, 1, reinterpret_cast(&pWkstaUserInfo),
MAX_PREFERRED_LENGTH, &entriesread, &totalentries, NULL);
if(status != NERR_Success)
{
PrintNetApiError(status);
throw status;
}
 
secLevels[0] = ::SysAllocString(L"Allow");
secLevels[1] = ::SysAllocString(L"Deny");
secLevels[2] = ::SysAllocString(L"Monitor");
secLevels[3] = ::SysAllocString(L"Undefined"");
saSecLevels.CreateOneDim(VT_BSTR, 4, secLevels);

for(unsigned i = 0; i < entriesread; i++)
{
fullName.Format(L"%s\\%s", pWkstaUserInfo[i].wkui1_logon_domain,
pWkstaUserInfo[i].wkui1_username);
propUserLevel.AddProperty(resourceText, fullName, saSecLevels, _T(""), ButtonNone, true);
}
 

 
By default I have the 1st value (etc "Allow"). But what can I do if I want to get for example "Undefined" during the initialization. How can I set SAFEARRAY value properly?
Please tell me about it?

GeneralActiveX contol propertiesmemberAlton Williams10 May '06 - 4:44 
Brilliant!!
My problem is that when I creating a control. I would like to set a property one of a set amount of states (BorderStyle in your case)
 
BorderNone = 0 - No border
BorderRaized = 1 - EDGE_RAISED
BorderSunken = 2 - EDGE_SUNKEN
BorderFlat = 3 - BDR_RAISEDOUTER|BDR_RAISEDINNER, BF_FLAT
BorderStatic = 4 - BDR_SUNKENINNER
 
How is this achieved?
Many thanks, Alton
GeneralRe: ActiveX contol propertiesmemberAlex Hazanov22 May '06 - 2:02 
What language are you using? C++, VB, script?
 

Creative minds - create creative creations!

GeneralMy question answered:memberAlton Williams30 May '06 - 4:33 
The answer to my question is the odl file.
Had I had bothered to read the code.D'Oh! | :doh:
Alton Williams wrote:
BorderNone = 0 - No border
BorderRaized = 1 - EDGE_RAISED
BorderSunken = 2 - EDGE_SUNKEN
BorderFlat = 3 - BDR_RAISEDOUTER|BDR_RAISEDINNER, BF_FLAT
BorderStatic = 4 - BDR_SUNKENINNER

 
I would had seen the above was in an enum and decalred it as that type instead of a short.Cool | :cool:
 
Thanks anyway,
AltonCool | :cool:

Generalbug : coud not redraw window validmembersillyemperor22 Jan '06 - 19:20 
i embed PropList ctrl in a float bar,and when a WM_ERASEBKGND occured,the ctrl coudle not redraw window valid,there is always remain a area could not be drawn.i have no idel about what is wrong.
QuestionJavascript combobox problemsmemberCoMiKe14 Dec '05 - 2:51 
Hi, Mr. Hazanov!
 
What a great control you have coded!
 
Anyway, I'm having problems to create a combobox using javascript in an HTML page.
 
Instead of having a combobox created, a button is shown preceded by the text "Nothing selected".
 
This is the code I'm using:
<html>
     <head>
          <script language="javascript">
               function populate() {
                    var values = new Array(3);
                    values[0] = "Test1";
                    values[1] = "Test2";
                    values[2] = "Test3";
                    pp.AddProperty("Group", "Caption", values, "Description", 0, 1);
               }
          </script>
     </head>
     <body onload="populate();">
          <object name="pp" classid="clsid:75C461D9-9588-415A-8D8F-4EA2430703B9" width="200" height="500">
               <param name="ShowDescription" value="0">
          </object>
     </body>
</html>
 
I hope you can test it and fix it (if it's a bug), or tell me how to create combo boxes using Javascript.
 
Oh, and it would be great if comboboxes wouldn't be limited to the listed values (I mean, editable comboboxes).
 
Good work!!
 
Greetings.
-------------
CoMiKe
AnswerRe: Javascript combobox problemsmemberAlex Hazanov14 Dec '05 - 4:57 
I would suggest using VB script instead since JavaScript has some strange way to represent arrays, and they aren't always easy to read in C++
 
You could setup some VBScript function just for that purpose and call it from JScript
 
I'll try to look in teh code what could be wrong (since I remember myself using JScript with the control) , but I can't promise taht it would be in the next couple of days , since my hands are full at the moment.
 

Creative minds - create creative creations!

GeneralRe: Javascript combobox problemsmemberCoMiKe14 Dec '05 - 13:16 
Alex Hazanov wrote:
You could setup some VBScript function just for that purpose and call it from JScript

Thanks for the suggestion, I will try!
 
Alex Hazanov wrote:
I'll try to look in teh code what could be wrong (since I remember myself using JScript with the control) , but I can't promise taht it would be in the next couple of days , since my hands are full at the moment.

 
My intention is to write a CSS editor for Maxthon Browser, and you control would fit very well for the job.
 
Thanks for you reply and your interest!
GeneralRe: Javascript combobox problemsmemberCoMiKe15 Dec '05 - 1:54 
It doesn't work using vbscript either, though in this case, a non-editable control is created after the caption. This is the code I'm using:
 
<html>
     <head>
          <script language="vbscript">
               function populate()
                    dim values(3)
                    values(0) = "Test1"
                    values(1) = "Test2"
                    values(2) = "Test3"
                    pp.AddProperty "Group", "Caption", values, "Description", 0, 1
               end function
          </script>
     </head>
     <body onload="populate()">
          <object name="pp" classid="clsid:75C461D9-9588-415A-8D8F-4EA2430703B9" width="200" height="500">
               <param name="ShowDescription" value="0">
          </object>
     </body>
</html>
 
Good luck! Smile | :)
 
-- modified at 7:59 Thursday 15th December, 2005
GeneralWell Donemembervalladis16 Aug '05 - 3:14 
Laugh | :laugh:
That has become quite a rare thing to get so pleased from other's work.
 
Great API and very clear design.
Thank you for this one.
 

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

Permalink | Advertise | Privacy | Mobile
Web03 | 2.6.130523.1 | Last Updated 5 Nov 2004
Article Copyright 2004 by Alex Hazanov
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid