Sign in to follow this  
Followers 0
quick_sliver007

GUICtrlSetImage is pressing the button..

5 posts in this topic

I am using GUICtrlSetImage on a button and it is changing $msg

"$msg = GUIGetMsg()" to that button. Does any one have any Ideal how to stop it from doing that. I just want it to change the picture on the button, not press it too.


.

Share this post


Link to post
Share on other sites



post your code....


[u]Do more with pre-existing apps![/u]ANYGUIv2.8

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

post your code....

<{POST_SNAPBACK}>

#include <GuiConstants.au3>
;#include <Array.au3>
#include <Misc.au3>

AutoItSetOption("trayicondebug", 1)

GUICreate("MyGUI", 392, 323, (@DesktopWidth - 392) / 2, (@DesktopHeight - 323) / 2, $ws_overlappedwindow + $ws_visible + $ws_clipsiblings)
Dim $buttons[5]
$buttons[0] = ""
$buttons[1] = GUICtrlCreateButton("", 20, 30, 150, 110, $bs_bitmap)
GUICtrlSetImage($buttons[1], "darkred.bmp")
$buttons[2] = GUICtrlCreateButton("", 20, 170, 150, 110, $bs_bitmap)
GUICtrlSetImage($buttons[2], "darkblue.bmp")
$buttons[3] = GUICtrlCreateButton("", 210, 30, 150, 110, $bs_bitmap)
GUICtrlSetImage($buttons[3], "darkyellow.bmp")
$buttons[4] = GUICtrlCreateButton("", 210, 170, 150, 110, $bs_bitmap)
GUICtrlSetImage($buttons[4], "darkgreen.bmp")
GUISetState()
Global $count = 1
Global $count2 = 0
Global $color = ""

$random = ""
_play()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $gui_event_close
            ExitLoop
        Case $msg = $buttons[1]
            _getbuttons("red.bmp")
        Case $msg = $buttons[2]
            _getbuttons("blue.bmp")
        Case $buttons[3]
            _getbuttons("yellow.bmp")
        Case $buttons[4]
            _getbuttons("green.bmp")
    EndSelect
WEnd
Exit
#endregion --- GuiBuilder generated code End ---
Func _play()
    
    Do
        
        $count2 = $count2 + 1
        $r = Int(Random(1, 4))
        If $r = 1 Then
            $color = $color & "/" & "red.bmp"
        ElseIf $r = 2 Then
            $color = $color & "/" & "blue.bmp"
        ElseIf $r = 3 Then
            $color = $color & "/" & "yellow.bmp"
        ElseIf $r = 4 Then
            $color = $color & "/" & "green.bmp"
        EndIf
        $random = $random & "/" & $r
        $color_array = StringSplit($color, "/")
        $random_array = StringSplit($random, "/")
    ;_ArrayDisplay($color_array, $color)
    ;_ArrayDisplay($random_array, $random)
        
        
        For $b = 1 To $count2 + 1
            Sleep(500)
        ;;;;;GUICtrlSetState($buttons[$random_array[$b]],$GUI_DISABLE)
            GUICtrlSetImage($buttons[$random_array[$b]], "light" & $color_array[$b])
            Sleep(500)
            
            GUICtrlSetImage($buttons[$random_array[$b]], "dark" & $color_array[$b])
    ;;;;;;;;;;;GUICtrlSetState($buttons[$random_array[$b]],$GUI_ENABLE)
        Next
        
    Until $count2 = $count
    $count = $count + 1
    Return $count
    Return $count2
    Return $color
    Return $random
EndFunc  ;==>_play
Func _getbuttons($getcolor)
    
    $buttons[0] = $buttons[0] & "/"&$getcolor
    If $buttons[0] = $color Then
    MsgBox(0,$buttons[0],$color)    
        _play()
    
    Else
    MsgBox(0, "You Lose", "You matched the color "&_Iif ($count2 - 1 > 1, "s", "" )& $count2 - 1 & " times")    
    EndIf
    Return $buttons[0]
EndFunc
Edited by quick_sliver007

.

Share this post


Link to post
Share on other sites

Case $buttons[3]
            _getbuttons("yellow.bmp")
        Case $buttons[4]
            _getbuttons("green.bmp")

should be

Case $msg = $buttons[3]
            _getbuttons("yellow.bmp")
        Case $msg = $buttons[4]
            _getbuttons("green.bmp")

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Case $buttons[3]
            _getbuttons("yellow.bmp")
        Case $buttons[4]
            _getbuttons("green.bmp")

should be

Case $msg = $buttons[3]
            _getbuttons("yellow.bmp")
        Case $msg = $buttons[4]
            _getbuttons("green.bmp")

<{POST_SNAPBACK}>

LOL, :( I knew it had to be something dumb. Thanks man

.

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