Sign in to follow this  
Followers 0
Jikoo

Get text from Edit of ComboBox with icon ! [SOLVED]

3 posts in this topic

#1 ·  Posted (edited)

Hello everybody,

I would like to know if it's possible to get text from Edit of ComboBoxEx with icon ?

There is no problem on this following script. But when I delete $CBS_SIMPLE, it doesn't work. I would like an icon in Edit like many softwares... and get text ! Thank you very much.

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

Opt('MustDeclareVars', 1)


_Main()

Func _Main()
    Local $msg, $hGUI, $hImage, $combobox, $button


    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Get Text with Icon", 400, 300)
    $combobox = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100, $CBS_SIMPLE)
    GUISetState()

    $button = GUICtrlCreateButton("Get text", 50, 150, 100, 20)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)

    For $x = 0 To 20
        _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", $x)
    Next

    _GUICtrlComboBoxEx_SetImageList($combobox, $hImage)

    _GUICtrlComboBoxEx_InitStorage($combobox, 150, 300)

    _GUICtrlComboBoxEx_BeginUpdate($combobox)

    For $x = 0 To 20
        _GUICtrlComboBoxEx_AddString($combobox, StringFormat("%03d : Random string", Random(1, 200, 1)), $x, $x)
    Next

    _GUICtrlComboBoxEx_EndUpdate($combobox)
    
    While 1
        $msg = GUIGetMsg()
        Switch $msg
            Case $GUI_EVENT_CLOSE
                ExitLoop
                
            Case $button
                MsgBox(4160, "Information", "Edit Text: " & _GUICtrlComboBoxEx_GetEditText($combobox))
                
        EndSwitch
    WEnd
EndFunc   ;==>_Main
Edited by Jikoo

My projects : GCS Search 1.07 (GUI Control Styles Search)* Multilingual tool to help about the old scripts, with a dynamic menu.* Easy way to find missing Include files in old scripts downloaded from forums !* Famous Monoceres script added and improved (visual, drag and drop, automatic)* There is an interactive color converter with palettes too, for fun !The best way to start Autoit3 development (for newbies).

Share this post


Link to post
Share on other sites



Example:

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

Opt('MustDeclareVars', 1)


_Main()

Func _Main()
    Local $msg, $hGUI, $hImage, $combobox, $button, $sText
    
    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Get Text with Icon", 400, 300)
    $combobox = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100)
    GUISetState()

    $button = GUICtrlCreateButton("Get text", 50, 150, 100, 20)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)

    For $x = 0 To 20
        _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", $x)
    Next

    _GUICtrlComboBoxEx_SetImageList($combobox, $hImage)

    _GUICtrlComboBoxEx_InitStorage($combobox, 150, 300)

    _GUICtrlComboBoxEx_BeginUpdate($combobox)

    For $x = 0 To 20
        _GUICtrlComboBoxEx_AddString($combobox, StringFormat("%03d : Random string", Random(1, 200, 1)), $x, $x)
    Next

    _GUICtrlComboBoxEx_EndUpdate($combobox)
    
    While 1
        $msg = GUIGetMsg()
        Switch $msg
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $button
                _GUICtrlComboBoxEx_GetItemText($combobox, _GUICtrlComboBoxEx_GetCurSel($combobox), $sText)
                MsgBox(4160, "Information", "Edit Text: " & $sText)
        EndSwitch
    WEnd
EndFunc   ;==>_Main

:P

Share this post


Link to post
Share on other sites

Thank you very much rasim,

It works very well. :P


My projects : GCS Search 1.07 (GUI Control Styles Search)* Multilingual tool to help about the old scripts, with a dynamic menu.* Easy way to find missing Include files in old scripts downloaded from forums !* Famous Monoceres script added and improved (visual, drag and drop, automatic)* There is an interactive color converter with palettes too, for fun !The best way to start Autoit3 development (for newbies).

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