Sign in to follow this  
Followers 0
chenxu

_GUICtrlComboBox_GetEditText do not work properly when reading a combobox with Chinese characters

3 posts in this topic

This is a simple example which exactly describes what I mean, just select an item contains Chinese characters and press the button.

#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GUIComboBox.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>

Opt('MustDeclareVars', 1)

Global $hCombo

_Main()

Func _Main()
    Local $hGUI

    ; Create GUI
    $hGUI = GUICreate("(UDF) ComboBox Create", 400, 296)
    $hCombo = _GUICtrlComboBox_Create($hGUI, "中文|这是一些中文|Chinese characters", 2, 2, 396, 296)
    GUISetState()
    
    Global $b = GUICtrlCreateButton("Read", 2, 40)
    GUICtrlSetOnEvent ($b, "_read")

    Local $msg
    While 1
        $msg = GUIGetMsg()
        If $msg == $b Then _read()
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
    GUIDelete()
EndFunc   ;==>_Main

Func _read()
    Local $txt = _GUICtrlComboBox_GetEditText ($hCombo)
    MsgBox(0, "Read", "Not display the entire text of item which contains Chinese characters:" & @CRLF  & @CRLF & $txt)
EndFunc

Share this post


Link to post
Share on other sites

Try to use GUICtrlRead($hCombo).

Share this post


Link to post
Share on other sites

Try to use GUICtrlRead($hCombo).

Yes, I tried this function, it works. But there is another problem about this function. When the combobox drops down ( display the items), and move my mouse over an item in the rectangle, GUICtrlRead will read the text of the item under my mouse even I do not select the item. This is what I do not want.

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0