Jump to content
Sign in to follow this  
Aceguy

Live Combo.

Recommended Posts

BrettF

when using a combo box, is there a way to update a label while selecting the contents of a combo box, (beofre confirming selection)

:D many thanks

I did this in the shell comp... :P

$shtdpwn = GUICreate("Shudown", 213, 183)
    $Label1 = GUICtrlCreateLabel("What would you like your computer to do?", 4, 4, 203, 17)
    $CboShutdown = GUICtrlCreateCombo("", 4, 28, 205, 25, $CBS_DROPDOWNLIST)
    GUICtrlSetData(-1, "Exit|Standby|Shutdown|Reboot|Hibernate", "Exit")
    $lblabout = GUICtrlCreateLabel("Exits this program", 4, 80, 203, 50)
    $btnOK = GUICtrlCreateButton("OK", 132, 152, 75, 25)
    GUICtrlSetState(-1, $GUI_DEFBUTTON)
    $btnCancel = GUICtrlCreateButton("Cancel", 52, 152, 75, 25)
    $chkForce = GUICtrlCreateCheckbox("Force", 4, 56, 201, 17)
    GUISetState(@SW_SHOW)
    
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $CboShutdown Or $msg = $chkForce
                $Shutdown = GUICtrlRead($CboShutdown)
                Select
                    Case $Shutdown = "Exit" 
                        $code = "Exits this program" 
                    Case $Shutdown = "Standby" 
                        $code = "Will send the computer into Standby Mode" 
                    Case $Shutdown = "Shutdown" 
                        $code = "Will shutdown this computer" 
                    Case $Shutdown = "Reboot" 
                        $code = "Will restart this computer" 
                    Case $Shutdown = "Hibernate" 
                        $code = "Will hibernate this computer, saving the current settings." 
                EndSelect
                If GUICtrlRead($chkForce) = $GUI_CHECKED Then
                    $code += @CRLF & @CRLF & "Force the current action" 
                EndIf
                GUICtrlSetData($lblabout, $code)
            Case $msg = $btnOK
                $Shutdown = GUICtrlRead($CboShutdown)
                $code = 0
                Select
                    Case $Shutdown = "Exit" 
                        $code = 0
                    Case $Shutdown = "Standby" 
                        $code = 32
                    Case $Shutdown = "Shutdown" 
                        $code = 1
                    Case $Shutdown = "Reboot" 
                        $code = 2
                    Case $Shutdown = "Hibernate" 
                        $code = 64
                EndSelect
                If GUICtrlGetState($chkForce) = $GUI_CHECKED Then
                    $code += 4
                EndIf
                If $code = 0 Then
                    Exit
                Else
                    MsgBox(0, "", "SHUTDOWN: " & $code)
                ;Shutdown ($code)
                    Exit
                EndIf
            Case $msg = $btnCancel
                ExitLoop
        EndSelect
    WEnd
    GUIDelete($shtdpwn)

Share this post


Link to post
Share on other sites
erezlevi

don't forget to put #include <GUIconstants.au3> at the begining, but it is great Example as allways bret you are amaizing!

Share this post


Link to post
Share on other sites
BrettF

don't forget to put #include <GUIconstants.au3> at the begining, but it is great Example as allways bret you are amaizing!

And remember that you will have to use specific constants in future versions. GUIConstants.au3 will be "deflated" soon... :P or something like that... Erm... Thanks?? :D Edited by Bert

Share this post


Link to post
Share on other sites
BrettF

thanks for quick reply, Altho im after it udating whats under the mouse pointer .

ie.

click combo to bring list up,

using mouse pointer to update the $label to whats under the mouse.?

Mate, you making about as much sense a kookaburra. I don't understand what you are asking.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.