KEHT Posted September 23, 2014 Share Posted September 23, 2014 Hello again guys! I ran into another problem I am trying to solve. I have a ComboBox control with a long list of names. When one of them is selected its value is added to a List control below. The problem I am having is that when a name is selected in a combobox and mouse wheel is scrolled all the names that are scrolled through get added to a List control below. My users indicated this as undesirable behavior. I am not sure whether it is a default or not, but I'm trying to get rid of it. I tried shifting focus after the name is selected, but it did not work too well. I am now trying to figure out a way to only allow selection when ComboBox is extended or only allow selection specifically by clicking left mouse button. Can anybody provide any suggestions??? Link to comment Share on other sites More sharing options...
jdelaney Posted September 23, 2014 Share Posted September 23, 2014 (edited) You can add a button, and only add the selected 'combo' value when the 'add' button is clicked. Edited September 23, 2014 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
KEHT Posted September 23, 2014 Author Share Posted September 23, 2014 You can add a button, and only add the selected 'combo' value when the 'add' button is clicked. Unfortunately, that's not an option in my case as I am limited by the requirements to have the same number and type of elements as the previous version of software I am recreating. Link to comment Share on other sites More sharing options...
jdelaney Posted September 23, 2014 Share Posted September 23, 2014 (edited) Then you have to key off the click, and not the change in text. Maybe loss of focus will do you. Edited September 23, 2014 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
Moderators Solution Melba23 Posted September 23, 2014 Moderators Solution Share Posted September 23, 2014 (edited) KEHT,I would do it like this:expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiComboBox.au3> ; Flag to show if combo has dropped Global $bSelected = False $hGUI = GUICreate("Test", 500, 500) $cCombo = GUICtrlCreateCombo("", 10, 10, 200, 20) GUICtrlSetData($cCombo, "1|2|3|4|5|6|7|8|9") $cList = GUICtrlCreateList("", 10, 100, 200, 200, BitOR($WS_BORDER, $WS_VSCROLL)) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cCombo ; If combo has dropped If $bSelected Then ; Clear flag $bSelected = False ; Add data GUICtrlSetData($cList, GUICtrlRead($cCombo)) EndIf EndSwitch ; look for combo dropping If _GUICtrlComboBox_GetDroppedState($cCombo) Then ; Set flag $bSelected = True EndIf WEndYou could probably look for a message that the combo has been dropped rather then polling in the loop - but I leave that to you to code. Please ask if anything is unclear. M23Edit:Actually the message code is really easy, so here it is: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiComboBox.au3> ; Flag to show if combo has dropped Global $bSelected = False $hGUI = GUICreate("Test", 500, 500) $cCombo = GUICtrlCreateCombo("", 10, 10, 200, 20) GUICtrlSetData($cCombo, "1|2|3|4|5|6|7|8|9") $cList = GUICtrlCreateList("", 10, 100, 200, 200, BitOR($WS_BORDER, $WS_VSCROLL)) GUISetState() GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cCombo ; If combo has dropped If $bSelected Then ; Clear flag $bSelected = False ; Add data GUICtrlSetData($cList, GUICtrlRead($cCombo)) EndIf EndSwitch WEnd Func _WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) If _WinAPI_HiWord($wParam) = $CBN_DROPDOWN Then ; Set flag $bSelected = True EndIf EndFunc Edited September 23, 2014 by Melba23 KEHT 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
KEHT Posted September 23, 2014 Author Share Posted September 23, 2014 Thanks, @Melba23 !!! That did the trick perfectly!!! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now