Sign in to follow this  
Followers 0
Valik

HistoryCombo control

8 posts in this topic

Here is what I've named a "HistoryCombo". It uses the COM interface for the ComboBoxEx/ImageCombo control provided by Microsoft (This control may not be available on all versions of Windows). This is basically a run-of-the-mill ComboBox control except it supports a couple keyboard events. Pressing Enter will add the contents of the ComboBox's edit control to the list. Pressing Ctrl+Delete will delete the currently selected item from the list. Both of these keyboard commands are pretty standard when a ComboBox keeps a history. Implementing this sort of functionality using AutoIt's ComboBox control is more difficult because it requires using _IsPressed() or HotKeySet().

Attached below is the library. The API itself is a little inconsistent and some things may be missing. It basically implements little more than what I needed out of the library.

Attached below here is a test script that allows you to play around with 2 instances of the control. You can experiment with the keyboard events and see how the control behaves here. Pressing the button on the GUI will print to the console (Best viewed from SciTE) the stuff currently in each HistoryCombo control. The script also serves as a basic example of creating the control and harvesting data from it when you're done.

Here is an excerpt listing all the public functions. There are other functions but they should not be called from user-code.

_HistoryComboCreate($hParent, $x, $y, $w = Default, $h = Default) - Creates a new instance of the HistoryCombo control.

_HistoryComboDestroy(ByRef $aCombo) - Destroys a HistorCombo control.

_HistoryComboSetPosition($aCombo, $x, $y, $w, $h) - Sets the position of the control.

_HistoryComboSetSelected(ByRef $vCombo, $vSelect) - Sets the selected item in the control.

_HistoryComboGetSelected(ByRef $vCombo) - Retrieves the text of the selected item.

_HistoryComboAddItem(ByRef $vCombo, $sText, $bUnique = True) - Adds a new item to the list.

_HistoryComboRemoveItem(ByRef $vCombo, $nIndex) - Removes an item from the list based on index.

_HistoryComboAddList(ByRef $vCombo, $sList, $sDelimiter = "|") - Adds a delimited list to the control.

_HistoryComboGetList(ByRef $vCombo, $sDelimiter = "|") - Retrieves a delimited list of items in the control.

_HistoryComboGetObj(ByRef $vCombo) - Retrieves the COM object for the ComboBox control.

_HistoryComboGetControlID(ByRef $aCombo) - Retrieves the controld ID of the ActiveX control.

_HistoryComboGetEventObj(ByRef $aCombo) - Retrieves the COM event sink object.

_HistoryComboShowDropdown(ByRef $vCombo, $bShow = True) - Displays or hides the dropdown list.

_HistoryComboIsDropped(ByRef $vCombo) - Retrieve the visibility state of the dropdown list.

Share this post


Link to post
Share on other sites



SvenP has informed me of two significant limitations on the Microsoft COM object I'm using so it's probably not going to work on most people's machines. One of the limitations is that it's probably only on Windows XP. The other is that it requires a Microsoft SDK in order to have a license present to even use the control. So if you try to use it but can't, one of the above reasons is likely why.

Share this post


Link to post
Share on other sites

SvenP has informed me of two significant limitations on the Microsoft COM object I'm using so it's probably not going to work on most people's machines. One of the limitations is that it's probably only on Windows XP. The other is that it requires a Microsoft SDK in order to have a license present to even use the control. So if you try to use it but can't, one of the above reasons is likely why.

Valik... You're coding is awesome!!

Quick question, from what SvenP has told you... what 'specific' UDF(s) that you've created are so called 'Obsolete'? Can it really be all of them or just the ones you reference com to?


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

This library posted in this thread. If you can't create the object, the whole thing is worthless to most people, and most people aren't going to be able to create the object that this library is based on.

Share this post


Link to post
Share on other sites

Thanks to Holger and GUIRegisterMsg(), I'm now able to capture the keyboard events using AutoIt's built-in ComboBox control. When I find time, I will port this library to use that and it will actually be usable for people, then.

Share this post


Link to post
Share on other sites

Hello there, i've managed to select an existing combobox item by using _IEHeadInsertEventScript , but the thing is that the script only execute the last instruction, it doesn't execute all the onclick instructions at the same time. can you help me? what can i do?

Here in the code you can see two instructions but it only executes the last instructions when i click with the mouse for example.

_IEHeadInsertEventScript ($oIE, "document", "onclick", "FullList('8224', Form1.nomProfesion, lisoficioprofesion);")

_IEHeadInsertEventScript ($oIE, "document", "onclick", "FullList('8224', Form1.nomOcupacion, lisoficioprofesion);")

Share this post


Link to post
Share on other sites

What does that have to do with this thread?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0