4Eyes Posted September 12, 2009 Share Posted September 12, 2009 Folks, How do I know if the edit box of a combobox has been changed? Do I need to mod the example for _GUICtrlComboBox_AutoComplete? Regards, 4Eyes Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted September 12, 2009 Moderators Share Posted September 12, 2009 You can probably register a WM_COMMAND message using EN_CHANGE, and get the handle of the edit control of the combobox using _GUICtrlComboBoxEx_GetEditControl(). I'll play a bit later if you can't figure it out ( And I remember to look at this thread again lol ) 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. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted September 12, 2009 Moderators Share Posted September 12, 2009 Here, quick and dirty:expandcollapse popup#include <GuiComboBoxEx.au3> #include <GuiImageList.au3> #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) Global $h_combo_edit = 0 Global $hGUI, $hImage, $hCombo ; Create GUI $hGUI = GUICreate("ComboBoxEx Get Edit Control", 400, 300) $hCombo = _GUICtrlComboBoxEx_Create ($hGUI, "", 2, 2, 394, 268) $h_combo_edit = _GUICtrlComboBoxEx_GetComboControl($hCombo) GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") GUISetState() $hImage = _GUIImageList_Create (16, 16, 5, 3) _GUIImageList_AddIcon ($hImage, @SystemDir & "\shell32.dll", 110) _GUIImageList_AddIcon ($hImage, @SystemDir & "\shell32.dll", 131) _GUIImageList_AddIcon ($hImage, @SystemDir & "\shell32.dll", 165) _GUIImageList_AddIcon ($hImage, @SystemDir & "\shell32.dll", 168) _GUIImageList_AddIcon ($hImage, @SystemDir & "\shell32.dll", 137) _GUIImageList_AddIcon ($hImage, @SystemDir & "\shell32.dll", 146) _GUICtrlComboBoxEx_SetImageList ($hCombo, $hImage) For $x = 0 To 5 _GUICtrlComboBoxEx_AddString ($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)), $x) Next ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func _WM_COMMAND($h_wnd, $i_msg, $w_param, $l_param) #forceref $h_wnd, $i_msg, $w_param, $l_param Local $i_command_code = BitAND($w_param, 0xFFFF) Local $i_command_notify = BitShift($w_param, 16) Switch $l_param Case $hCombo Switch $i_command_notify Case $CBN_EDITCHANGE ConsoleWrite("combo edit -> CBN_EDITCHANGE -> " & ControlGetText($hGUI, "", $hCombo) & @CRLF) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc 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. Link to comment Share on other sites More sharing options...
4Eyes Posted September 12, 2009 Author Share Posted September 12, 2009 (edited) SmOke_N, I'm already using a WM_COMMAND to detect double clicks in a ListView. Looks like I need a 2nd one monitoring $CBN_EDITCHANGE. The _GUICtrlComboBox_AutoComplete example is a little confusing but I'll see if I can work it out. Thanks for your suggestion. 4Eyes PS While I was thinking about replying, you already had. Thank you. BTW, your example needs the addition of: #include <GUIComboBox.au3> #Include <GuiComboBoxEx.au3> Edited September 12, 2009 by 4Eyes Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted September 12, 2009 Moderators Share Posted September 12, 2009 SmOke_N,I'm already using a WM_COMMAND to detect double clicks in a ListView. Looks like I need a 2nd one monitoring $CBN_EDITCHANGE. The _GUICtrlComboBox_AutoComplete example is a little confusing but I'll see if I can work it out.Thanks for your suggestion.4EyesGuess you were typing that when I posted an example.You don't need a 2nd WM_COMMAND (wouldn't work anyway). You just need to manage it, I gave you code to do that .. 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. Link to comment Share on other sites More sharing options...
4Eyes Posted September 13, 2009 Author Share Posted September 13, 2009 (edited) SmOke_N, Thanks again. If I need to monitor 2 different Windows message types, wouldn't I need to register two messages, 1 for WM_NOTIFY, the other for $WM_COMMAND? The help file says 'Up to 256 user functions can be registered for message ID's.' Maybe I misinterpreted what you are saying. I'll give it a go and see. 4Eyes Edited September 13, 2009 by 4Eyes Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted September 13, 2009 Moderators Share Posted September 13, 2009 SmOke_N,Thanks again. If I need to monitor 2 different Windows message types, wouldn't I need to register two messages, 1 for WM_NOTIFY, the other for $WM_COMMAND? The help file says 'Up to 256 user functions can be registered for message ID's.' Maybe I misinterpreted what you are saying.I'll give it a go and see.4EyesI have no idea what you have in your script. So asking this question you've asked is really... Well... Quite silly.They are two different messages... You ask " 1 for, or the other for", ... well, all I can say is yes, if it suits your needs. 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. Link to comment Share on other sites More sharing options...
4Eyes Posted September 14, 2009 Author Share Posted September 14, 2009 (edited) SmOke_N Ah, I see. I meant to say register 2 different types of messages not 2 handlers for 1 type of message. I have a handler (correct term?) for WM_NOTIFY and now a 2nd for $CBN_EDITCHANGE. My bad. Got it working well after fixing a few issues: - as I use some parameters with the control creation like this: _GUICtrlComboBoxEx_Create($guiP, "", 510, 70, 335, 155, BitOR($CBS_SIMPLE, $CBS_DISABLENOSCROLL, $WS_VSCROLL, $CBS_AUTOHSCROLL)) I had to use _GUICtrlComboBoxEx_GetEditText to read it else read nothing. Next, was triggering an event for the key down and another for key up. Found that $i_command_code = 1001 for keydown so now do a test for that. I need to track down the const (I assume there is one) for keydown to remain compatible with possible future changes of that value. Searching the includes for keydown finds $LVN_KEYDOWN and $NM_KEYDOWN but it's neither of these. Anybody care to nominate the correct one? Feels good to have this pretty much sorted. Thanks for your help. 4Eyes Edited September 14, 2009 by 4Eyes 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