Sign in to follow this  
Followers 0
Fossil Rock

Clicking on image control

9 posts in this topic

Is there an easy way to test when an image is clicked on? I specifically want to be able to determine which image is clicked on out of several images.

I'm working on a card game where all the cards are face down and when you click on a card it will flip over to reveal what it is. This is still in the concept stage, so I don't have much code to show.

Thanks


Agreement is not necessary - thinking for one's self is!

My-Colors.jpg

cuniform2.gif

Share this post


Link to post
Share on other sites



$pic = guictrlcreatepic()

while 1

$msg = guigetmsg()

if $msg = $pic then

; do something

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Thanks ... I'll give it a shot.


Agreement is not necessary - thinking for one's self is!

My-Colors.jpg

cuniform2.gif

Share this post


Link to post
Share on other sites

This isn't very smooth, can you give me hint as too way?

#include <GUIConstants.au3>

$C1 = "C:\Documents and Settings\All Users\Documents\Playing Cards\Card.gif"; Use any graphic
$C2 = "C:\Documents and Settings\All Users\Documents\Playing Cards\Cardback.gif"; Use any graphic

$C = $C2

$Form1 = GUICreate("Match Card Game", 251, 149, 413, 306)
$Pic1 = GUICtrlCreatePic($C, 32, 24, 40, 56, BitOR($SS_NOTIFY,$WS_GROUP))
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    $msg = GUIGetMsg($GUI_EVENT_PRIMARYDOWN)
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    Switch $msg = $Pic1
        Case $C = $C1
            $C = $C2
        Case $C = $C2
            $C = $C1
    EndSwitch
    GUICtrlSetImage($Pic1,$C)
WEnd

Agreement is not necessary - thinking for one's self is!

My-Colors.jpg

cuniform2.gif

Share this post


Link to post
Share on other sites

Hmm, I can say that that makes no sense lol... what is this:

$nMsg = GUIGetMsg()
    $msg = GUIGetMsg($GUI_EVENT_PRIMARYDOWN)
?


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

$nMsg = GUIGetMsg() - checks for close event

$msg = GUIGetMsg($GUI_EVENT_PRIMARYDOWN) - supposed to check for the mouse click down

guess it works with or without $GUI_EVENT_PRIMARYDOWN

Edited by Fossil Rock

Agreement is not necessary - thinking for one's self is!

My-Colors.jpg

cuniform2.gif

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

$nMsg = GUIGetMsg() - checks for close event

$msg = GUIGetMsg($GUI_EVENT_PRIMARYDOWN) - supposed to check for the mouse click down

guess it works with or without $GUI_EVENT_PRIMARYDOWN

Well $nMsg is going to be the same as $Msg, to check if $GUI_EVENT_PRIMARYDOWN was used you would do something like:

$nMsg = GUIGetMsg()
Select
    Case $nMsg = $GUI_EVENT_CLOSE
        Exit
    Case $nMsg = $GUI_EVENT_PRIMARYDOWN
      ;Do something
    Case $nMsg = $Pic1
      ;Do something
EndSelect
You only need one GUIGetMsg()

Edit:

Maybe you were trying for this type of affect?

#include <GUIConstants.au3>
Global $Down

Dim $CardUp = @DocumentsCommonDir & '\My Pictures\Sample Pictures\Sunset.jpg';"C:\Documents and Settings\All Users\Documents\Playing Cards\Card.gif"; Use any graphic
Dim $CardDown = @DocumentsCommonDir & '\My Pictures\Sample Pictures\Blue hills.jpg';"C:\Documents and Settings\All Users\Documents\Playing Cards\Cardback.gif"; Use any graphic

$Form1 = GUICreate("Match Card Game")
$Pic1 = GUICtrlCreatePic($CardDown, 10, 10, 300, 300)
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = - 3
            Exit
        Case $msg = $Pic1
            $Down = Not $Down
            If $Down Then
                GUICtrlDelete($Pic1)
                $Pic1 = GUICtrlCreatePic($CardUp, 10, 10, 300, 300)
            Else
                GUICtrlDelete($Pic1)
                $Pic1 = GUICtrlCreatePic($CardDown, 10, 10, 300, 300)
            EndIf
    EndSelect
WEnd
Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Thanks Smoke, It helped me understand better what I was doing and trying to accomplish.

This works much better, but still has a lag in it ....

#include <GUIConstants.au3>

$C1 = "C:\Documents and Settings\All Users\Documents\Playing Cards\2C.gif"
$C2 = "C:\Documents and Settings\All Users\Documents\Playing Cards\Cardback.bmp"

$C = $C2

$Form1 = GUICreate("Match Card Game", 251, 149, 413, 306)
$Pic1 = GUICtrlCreatePic($C, 32, 24, 40, 56, BitOR($SS_NOTIFY,$WS_GROUP))
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Select
        Case $nMsg = $GUI_EVENT_CLOSE
            Exit
        Case $nMsg = $Pic1
            Select 
                Case $C = $C1
                $C = $C2
                GUICtrlSetImage($Pic1,$C)
                Case $C = $C2
                $C = $C1
                GUICtrlSetImage($Pic1,$C)
            EndSelect
    EndSelect
WEnd

Agreement is not necessary - thinking for one's self is!

My-Colors.jpg

cuniform2.gif

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Well $nMsg is going to be the same as $Msg, to check if $GUI_EVENT_PRIMARYDOWN was used you would do something like:

$nMsg = GUIGetMsg()
Select
    Case $nMsg = $GUI_EVENT_CLOSE
        Exit
    Case $nMsg = $GUI_EVENT_PRIMARYDOWN
    ;Do something
    Case $nMsg = $Pic1
    ;Do something
EndSelect
You only need one GUIGetMsg()

Edit:

Maybe you were trying for this type of affect?

#include <GUIConstants.au3>
Global $Down

Dim $CardUp = @DocumentsCommonDir & '\My Pictures\Sample Pictures\Sunset.jpg';"C:\Documents and Settings\All Users\Documents\Playing Cards\Card.gif"; Use any graphic
Dim $CardDown = @DocumentsCommonDir & '\My Pictures\Sample Pictures\Blue hills.jpg';"C:\Documents and Settings\All Users\Documents\Playing Cards\Cardback.gif"; Use any graphic

$Form1 = GUICreate("Match Card Game")
$Pic1 = GUICtrlCreatePic($CardDown, 10, 10, 300, 300)
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = - 3
            Exit
        Case $msg = $Pic1
            $Down = Not $Down
            If $Down Then
                GUICtrlDelete($Pic1)
                $Pic1 = GUICtrlCreatePic($CardUp, 10, 10, 300, 300)
            Else
                GUICtrlDelete($Pic1)
                $Pic1 = GUICtrlCreatePic($CardDown, 10, 10, 300, 300)
            EndIf
    EndSelect
WEnd

uh, yep .... thanks

EDIT: your's is much faster ... thanks

Edited by Fossil Rock

Agreement is not necessary - thinking for one's self is!

My-Colors.jpg

cuniform2.gif

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