Jump to content

What data is returned when you read a combo list?


 Share

Recommended Posts

#include <GUIconstants.au3>
;~ #include <WindowsConstants.au3>

Global $hGui = GUICreate("Test", 200, 80)
Global $cmbCombo = GUICtrlCreateCombo("", 10, 10, 180, 60)

GUICtrlSetData($cmbCombo, "Item 1|Item 2|Item 3", "Item 1")

GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

GUISetState(@SW_SHOW, $hGui)

While (True)
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit 0
    EndSwitch
WEnd

Func WM_COMMAND($hWndFrom, $iMsg, $wParam, $lParam)
    Local $iIDFrom = BitAND($wParam, 0xFFFF) ; Low Word
    Local $iCode = BitShift($wParam, 16) ; Hi Word

    Switch ($hWndFrom)
        Case $hGui
            Switch $iCode
                Case $CBN_EDITCHANGE
                    ConsoleWrite("User is editing combo item, item '" & GUICtrlRead($cmbCombo) & "' is currently selected" & @LF)

                Case $CBN_SELCHANGE
                    ConsoleWrite("User changed combo item, item '" & GUICtrlRead($cmbCombo) & "' is currently selected" & @LF)
            EndSwitch
    EndSwitch
EndFunc

This might help you understand a little more. Check out _GUICtrlComboBox_Create, you can get some more functionality using the _GUICtrlComboBox UDF. Also $iIDFrom is used for the control id so if you had multiple Combo Boxes.

Link to comment
Share on other sites

No reason to be super hostile. You gotta realize a lot of people come here with simple questions that are answered 99.99% of the time in the help file. In some cases, at least I struggled with this, they don't know where to look in the help file.

You, on the other hand, had the GUICtrlRead already in your example.

GUICtrlRead

Read state or data of a control.

Combo, List: The value selected

And then there's the example for the GUICtrlCreateCombo

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Create a GUI with various controls.
    Local $hGUI = GUICreate("Example", 300, 200)

    ; Create a combobox control.
    Local $idComboBox = GUICtrlCreateCombo("Item 1", 10, 10, 185, 20)
    Local $idClose = GUICtrlCreateButton("Close", 210, 170, 85, 25)

    ; Add additional items to the combobox.
    GUICtrlSetData($idComboBox, "Item 2|Item 3", "Item 2")

    ; Display the GUI.
    GUISetState(@SW_SHOW, $hGUI)

    Local $sComboRead = ""

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idClose
                ExitLoop

            Case $idComboBox
                $sComboRead = GUICtrlRead($idComboBox)
                MsgBox($MB_SYSTEMMODAL, "", "The combobox is currently displaying: " & $sComboRead, 0, $hGUI)

        EndSwitch
    WEnd

    ; Delete the previous GUI and all controls.
    GUIDelete($hGUI)
EndFunc   ;==>Example

 

Link to comment
Share on other sites

He was just playing you guys.

He certainly is a real dumb-ass, but he isn't quite that dumb.

His racist ass will be banned shortly, no doubt, so I suggest we ignore him until then.

Edited by TheSaint

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

@InunoTaishou - I have noticed you have been very helpful at the forum regularly, and that is to be praised and admired.

But why would you give such a complex response to someone who seemingly couldn't even understand a Combo?

Edited by TheSaint

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

I chose to give an example that would constantly give output whenever the user would interact with the control. So they could see what was selected when they clicked an item in the combobox or started typing in the combobox. Just something he can play with since he was just asking what the value of GUICtrlRead would be.

Although I probably should have added more comments as to what they $iCodes were and how to activate them.

Edited by InunoTaishou
Link to comment
Share on other sites

And you don't think he would have seen any of that if he ran his own simple code, with say a MsgBox?

Your call, but personally I think it better to give code that can be understood simply and easily ... targeted to the level the questioning coder is at.

P.S. Don't let my investigative comments & critique discourage you from helping though. :D

Edited by TheSaint

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

  • Moderators

PEscobar,

As all you seem to ask about are gamebots, and now you have decided to grossly insult us all when offered pointers to answers that are easily available in the Help file, I think it best that you do indeed "quit the AutoIt forums". And to help you with this admirable desire, I will now ensure that you do.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...