Jump to content

Recommended Posts

Posted

Reading from the edit control of an comboboxEx with style $CBS_DROPDOWN $WS_VSCROLL

_GUICtrlComboBoxEX_GetEditText($Combo2)

I always get "".

But using the style $CBS_SIMPLE it works fine. I've added a code example to demostate the behavior (from the autoit documentation with some modifications):

#include <GuiComboBoxEx.au3>
#include <GuiImageList.au3>
#include <GuiConstantsEx.au3>

Opt('MustDeclareVars', 1)

$Debug_CB = False ; Check ClassName being passed to ComboBox/ComboBoxEx functions, set to True and use a handle to another control to see it work

_Main()

Func _Main()
    Local $hGUI, $hImage, $hCombo
    
    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Get Edit Text", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create ($hGUI, "", 2, 2, 394, 100); $CBS_SIMPLE removed!!! Gafrost knew it!
    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)
    _GUIImageList_Add ($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap ($hCombo, 0xFF0000, 16, 16))
    _GUIImageList_Add ($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap ($hCombo, 0x00FF00, 16, 16))
    _GUIImageList_Add ($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap ($hCombo, 0x0000FF, 16, 16))
    _GUICtrlComboBoxEx_SetImageList ($hCombo, $hImage)

    For $x = 0 To 8
        _GUICtrlComboBoxEx_AddString ($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)), $x, $x)
    Next
    
    ; Set Edit Text
    _GUICtrlComboBoxEx_SetEditText ($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)))
    
    ; Get Edit Text
    MsgBox(4160, "Information", "Edit Text: " & _GUICtrlComboBoxEx_GetEditText ($hCombo))
    
    Do
    ;Get Edit Text
    MsgBox(4160, "Information", "Edit Text: " & _GUICtrlComboBoxEx_GetEditText ($hCombo))
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>_Main

The same function works fine for normal combos _GUICtrlComboBox_GetEditText($hCombo).

Does anybody know a workaround or some other function I can call to get the text of the edit?

Many thanks in advance,

c.

  • 4 months later...
Posted

Hello,

It might be a little bit late, but I got the issue yesterday and solved it by "simply" adding this:

_GUICtrlComboBoxEx_BeginUpdate ($hCombo)

_GUICtrlComboBoxEx_EndUpdate ($hCombo)

before

_GUICtrlComboBoxEx_GetItemText ($hCombo, _GUICtrlComboBoxEx_GetCurSel($hCombo), $DestDim)

By checking with a MsgBox(0,"",$DestDim)

I can read the correct value.

Hope it will help...

Posted

If $CBS_DROPDOWN style is used, the edit control has a separate handle from the combo itself. That's why you have _GUICtrlComboBoxEx_GetEditControl():

While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                Exit
            Case $idButton
                $hEdit = _GUICtrlComboBoxEx_GetEditControl($hCombo)
                $sText = ControlGetText($hGUI, "", $hEdit)
                MsgBox(4160, "Information", "Edit Text: " & $sText)
        EndSwitch
    WEnd

:mellow:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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
×
×
  • Create New...