TheDcoder Posted December 12, 2015 Share Posted December 12, 2015 (edited) Hello , I am experiencing a problem with Combo controls... They get updated even before the user selects the item! Use this script to test this:#include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 366, 115, 301, 138) $Combo1 = GUICtrlCreateCombo("Combo1", 104, 24, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### GUICtrlSetData($Combo1, "Test") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch ConsoleWrite(GUICtrlRead($Combo1) & @CRLF) WEndTry hovering over "Test" (don't select it!) and watch the STDOUT stream (SciTE Output Panel located at the bottom of SciTE), it shows "Test" instead of "Combo1" Anyone know how to avoid this? Thanks in Advance, TD Edited December 12, 2015 by TheDcoder EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
JohnOne Posted December 12, 2015 Share Posted December 12, 2015 What?Are you smoking something young man? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
TheDcoder Posted December 12, 2015 Author Share Posted December 12, 2015 @JohnOne ? EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
JohnOne Posted December 12, 2015 Share Posted December 12, 2015 (edited) EDIT: Sorry, TD I misread your question? Edited December 12, 2015 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
JohnOne Posted December 12, 2015 Share Posted December 12, 2015 I imagine you would have to register a gui message, and prevent the default message from being sent on mouseover or enter or something.Sorry, for poor answer, It's all I have. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 12, 2015 Moderators Share Posted December 12, 2015 TheDcoder,Use a CueBanner like this:#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiComboBox.au3> $hGUI = GUICreate("Test", 500, 500) $cCombo = GUICtrlCreateCombo("", 10, 10, 200, 25) GUICtrlSetData($cCombo, "Test") _GUICtrlComboBox_SetCueBanner($cCombo, "Combo1") $cButton = GUICtrlCreateCheckbox("Test", 10, 100, 80, 30) GUICtrlSetState($cButton, $GUI_FOCUS) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch If GUICtrlRead($cCombo) Then ConsoleWrite(GUICtrlRead($cCombo) & @CRLF) EndIf WEndYou need the button because the CueBanner is only visible when the combo does not have focus.M23 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...
TheDcoder Posted December 13, 2015 Author Share Posted December 13, 2015 @Melba23 Not what I was expecting, I need all the elements to be in the combo EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
LarsJ Posted December 13, 2015 Share Posted December 13, 2015 You can try something like this:expandcollapse popup#include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListBox.au3> Global $bSelChanged = True #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 366, 115, 301, 138) $Combo1 = GUICtrlCreateCombo("Combo1", 104, 24, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUICtrlSetData($Combo1, "Test") GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch If $bSelChanged Then ConsoleWrite(GUICtrlRead($Combo1) & @CRLF) $bSelChanged = False EndIf WEnd Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg Local $hWndFrom, $iIDFrom, $iCode, $hWndListBox ;If Not IsHWnd($g_hListBox) Then $hWndListBox = GUICtrlGetHandle($g_hListBox) $hWndFrom = $lParam $iIDFrom = BitAND($wParam, 0xFFFF) ; Low Word $iCode = BitShift($wParam, 16) ; Hi Word ;Switch $hWndFrom ;Case $g_hListBox, $hWndListBox Switch $iCode Case $LBN_SELCHANGE ; Sent when the selection in a list box has changed $bSelChanged = True ; no return value EndSwitch ;EndSwitch Return $GUI_RUNDEFMSG EndFunc TheDcoder 1 Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 13, 2015 Moderators Share Posted December 13, 2015 TheDcoder,If all you want is to read the combo when it changes than just set a case for it:#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $hGUI = GUICreate("Test", 500, 500) $cCombo = GUICtrlCreateCombo("", 10, 10, 200, 25) GUICtrlSetData($cCombo, "Combo1|Test", "Combo1") GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cCombo ConsoleWrite(GUICtrlRead($cCombo) & @CRLF) EndSwitch WEndYou really do need to give more explanation of what you require when you post - far too often lately you have just thrown out a snippet and expected the community to work out what it is that you want to happen. Explaining in more detail means that others will not waste their time posting possible solutions which turn out not to be what you require.M23 TheDcoder 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...
TheDcoder Posted December 13, 2015 Author Share Posted December 13, 2015 @LarsJ Thanks for the solution but M23's solution seems better, sorry! @Melba23 That was astonishingly simple , Thanks! You really do need to give more explanation of what you require when you post - far too often lately you have just thrown out a snippet and expected the community to work out what it is that you want to happen...I will keep note of that.. The reason partly maybe that it was Midnight and I was sleepy when I posted my questions recently, sorry! EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
LarsJ Posted December 13, 2015 Share Posted December 13, 2015 You could at least have looked at GUICtrlCreateCombo in the help file. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
TheDcoder Posted December 13, 2015 Author Share Posted December 13, 2015 @LarsJ I did read the Remarks but ignored the example EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion 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