Jump to content

Recommended Posts

Posted (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 by belitre
Posted (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 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.

 

Posted

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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...