Jump to content

Display description for ComboBox


strongy
 Share

Recommended Posts

Hello,

I'm trying to figure out how to do this and it's beginning to hurt my head. 

I'm trying to display text when a ComboBox is selected to display a description of the content.  So far, if you drop down the ComboBox and move the mouse over the first line, the description changes to the ComboBox below which is not what I want. I'd like the content in $Group1 to remain for the duration of actions in that ComboBox. 

Does anyone have any ideas on this?  Thank you for your assistance. 

 

#include <GUIConstantsEx.au3>

$MainGUI = GUICreate("GUI", 594, 322, 192, 124)
$bExit = GUICtrlCreateButton("Exit", 432, 270, 75, 20)

$Label1 = GUICtrlCreateLabel("Test 1", 30, 75, 100, 20)
$Combo1 = GUICtrlCreateCombo("Combo1", 220, 75, 145, 80)
$Label2 = GUICtrlCreateLabel("Test 2", 30, 95, 185, 20)
$Combo2 = GUICtrlCreateCombo("Combo1", 220, 95, 145, 80)

$Group1 = GUICtrlCreateGroup("Item Description", 400, 60, 100, 180)
GUICtrlCreateGroup("", -99, -99, 1, 1)

GUISetState(@SW_SHOW)

While 1

    _mouseOver($Combo1)
    _mouseOver($Combo2)

    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $bExit
            Exit
    EndSwitch
WEnd

Func _mouseOver($comboSelected)
    Switch GUIGetCursorInfo($MainGUI)[4]
        Case $comboSelected
            If $comboSelected = $Combo1 Then
                If GUICtrlRead($Group1) <> "TEST" Then GUICtrlSetData($Group1, "TEST")
            EndIf
            If $comboSelected = $Combo2 Then
                If GUICtrlRead($Group1) <> "TEST2" Then GUICtrlSetData($Group1, "TEST2")
            EndIf
    EndSwitch

EndFunc   ;==>_mouseOver

 

Link to comment
Share on other sites

I am not exactly sure what you are trying to do from the description because you driving off the mouse on a function called _mouseOver which is what is changing the group text labels.  If you want it to be driven off of the selection of a combo control make that a case for the switch in your main GUI "while" loop.  Also, note: you gave each combo the same starting value of "Combo1".  Is this what you want to have happen?

#include <GUIConstantsEx.au3>

$MainGUI = GUICreate("GUI", 594, 322, 192, 124)
$bExit = GUICtrlCreateButton("Exit", 432, 270, 75, 20)

$Label1 = GUICtrlCreateLabel("Test 1", 30, 75, 100, 20)
$Combo1 = GUICtrlCreateCombo("Combo1", 220, 75, 145, 80)
$Label2 = GUICtrlCreateLabel("Test 2", 30, 95, 185, 20)
$Combo2 = GUICtrlCreateCombo("Combo2", 220, 95, 145, 80); I changed this to "Combo2"

$Group1 = GUICtrlCreateGroup("Item Description", 400, 60, 100, 180)
GUICtrlCreateGroup("", -99, -99, 1, 1)

GUISetState(@SW_SHOW)

While 1

    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Combo1
            if GUICtrlRead($Combo1)=="Combo1" then
                GUICtrlSetData($Group1,"You selected Combo 1")
            EndIf
        Case $Combo2
            if GUICtrlRead($Combo2)=="Combo2" then
                GUICtrlSetData($Group1,"You selected Combo 2")
            EndIf
        Case $bExit
            Exit
    EndSwitch
WEnd

 

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Link to comment
Share on other sites

Hi Jfish, thank you.

Maybe I should explain more..  The intention is to have 8 or so combo boxes with 3-4 configurations in each. I want to display information when the user "opens" or "hovers" the ComboBox to give a pre-description of the settings in each combo.  Kind of like advising them on what each setting will do. 

I do not plan to advise on what they have selected. 

Thanks. 

Link to comment
Share on other sites

Got it.  Try a "tooltip" - will work when you hover over the drop down in the combo (requires #include <GUIToolTip.au3>):

Local $comboID1 = GUICtrlGetHandle($Combo1)
Local $hToolTip = _GUIToolTip_Create(0)
_GUIToolTip_AddTool ( $hToolTip, $MainGUI, "This is to do something important",$comboID1,0, 10, 10, 168, 85, $TTF_SUBCLASS)

 

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Link to comment
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
 Share

  • Recently Browsing   0 members

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