belitre Posted April 12, 2006 Share Posted April 12, 2006 (edited) I've read several ways to count the items of a combobox. But I can't get them work. I show my tests: If (Not IsDeclared('CB_GETCOUNT')) Then Global Const $CB_GETCOUNT = 0x146 If (Not IsDeclared('CB_SETCURSEL')) Then Global Const $CB_SETCURSEL = 0x14E ;$hwndMainWindow is correctly initialized ;$strCtrlName is correctrly initialized $hwndComboBox = ControlGetHandle($hwndMainWindow, "", $strCtrlName) ControlFocus ( $hwndMainWindow, "", $hwndComboBox ) ; Next code works OK For $i = 1 To 3 DllCall("user32.dll", "int", "SendMessage", "hwnd", $hwndComboBox, "int", $CB_SETCURSEL, "int", $i, "int", 0) Sleep(1000) Next ; But none of next lines works for me: MsgBox(64,"Results", GUICtrlSendMsg($hwndComboBox, $CB_GETCOUNT, 0, 0) & " " & DllCall("user32.dll", "int", "SendMessage", "hwnd", $hwndComboBox, "int", $CB_GETCOUNT, "int", 0, "int", 0) & " " & GUICtrlRead($hwndComboBox) & " " & GUICtrlSendMsg($hwndComboBox, $CB_SETCURSEL, 1, 0)) Thanks in advance for your help. Edited April 19, 2006 by belitre Link to comment Share on other sites More sharing options...
GaryFrost Posted April 12, 2006 Share Posted April 12, 2006 (edited) might try (need beta): #include <GuiCombo.au3> ;$hwndMainWindow is correctly initialized ;$strCtrlName is correctrly initialized $hwndComboBox = ControlGetHandle($hwndMainWindow, "", $strCtrlName) ControlFocus ( $hwndMainWindow, "", $hwndComboBox ) For $i = 1 To 3 _GUICtrlComboSetCurSel($hwndComboBox, $i) Sleep(1000) Next MsgBox(64,"Results", _GUICtrlComboGetCount($hwndComboBox) & " " & _ _GUICtrlComboGetLBText($hwndComboBox,_GUICtrlComboGetCurSel($hwndComboBox)) & " " & _ _GUICtrlComboSetCurSel($hwndComboBox, 1)) Edited April 12, 2006 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
belitre Posted April 19, 2006 Author Share Posted April 19, 2006 might try (need beta): #include <GuiCombo.au3> ;$hwndMainWindow is correctly initialized ;$strCtrlName is correctrly initialized $hwndComboBox = ControlGetHandle($hwndMainWindow, "", $strCtrlName) ControlFocus ( $hwndMainWindow, "", $hwndComboBox ) For $i = 1 To 3 _GUICtrlComboSetCurSel($hwndComboBox, $i) Sleep(1000) Next MsgBox(64,"Results", _GUICtrlComboGetCount($hwndComboBox) & " " & _ _GUICtrlComboGetLBText($hwndComboBox,_GUICtrlComboGetCurSel($hwndComboBox)) & " " & _ _GUICtrlComboSetCurSel($hwndComboBox, 1)) Thank you very much. It works. Beta version is my official version now. 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