kag Posted April 29, 2011 Share Posted April 29, 2011 I'm trying to create a combobox with the edit control disabled AND the ability to read the currently selected item and/or index. It seems like I can do one or the other, but not both. If I disable the edit control, then _GUICtrlComboBox_GetEditText does not work. Here's the code: #include <GUIConstantsEx.au3> #include <ComboConstants.au3> #Include <GuiComboBox.au3> Opt('MustDeclareVars', 1) Opt("GUIOnEventMode", 1) Global $combo Example() Func Example() Local $msg $combo = GUICreate("My GUI combo") ; will create a dialog box that when displayed is centered GUICtrlCreateCombo("item1", 10, 10, -1, -1, $CBS_DROPDOWNLIST); create first item GUICtrlSetData(-1, "item2|item3", "item3"); add other item and set a new default GUISetState() GUICtrlSetOnEvent(-1, "ComboEvent") ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd EndFunc ;==>Example Func ComboEvent() local $text, $idx $text = _GUICtrlComboBox_GetEditText($combo) $idx = _GUICtrlComboBox_GetCurSel($combo) MsgBox(0, "ComboEvent", "idx = " & $idx & @CRLF & "text = " &$text) EndFunc Link to comment Share on other sites More sharing options...
UEZ Posted April 29, 2011 Share Posted April 29, 2011 You made some mistakes Try this: #include <GUIConstantsEx.au3> #include <ComboConstants.au3> #Include <GuiComboBox.au3> Opt('MustDeclareVars', 1) Opt("GUIOnEventMode", 1) Global $hgui = GUICreate("My GUI combo") ; will create a dialog box that when displayed is centered Global $combo = GUICtrlCreateCombo("item1", 10, 10, -1, -1, $CBS_DROPDOWNLIST); create first item GUICtrlSetData(-1, "item2|item3", "item3"); add other item and set a new default GUISetState() GUICtrlSetOnEvent(-1, "ComboEvent") GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") ; Run the GUI until the dialog is closed While Sleep(10000) WEnd Func ComboEvent() local $text, $idx $text = GUICtrlRead($combo) $idx = _GUICtrlComboBox_GetCurSel($combo) MsgBox(0, "ComboEvent", "idx = " & $idx & @CRLF & "text = " &$text) EndFunc Func _Exit() Exit EndFunc Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ 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