Sign in to follow this  
Followers 0
luvmachine

Layering Images and Detecting Clicks

3 posts in this topic

I'm trying to tell when a person clicks on a certain square on the grid so that I can have it list information correlated with that spot. As for now I'm just trying to get the script to be able to show the hero.jpg above the map_grid.jpg and still be able to tell when I click the hero.

It seems that it wants to logically detect the click based on how the various pic's were displayed as apposed to the top down view they are shown as.

Any help is appreciated ^^

#include "GuiConstants.au3"

Map_Test_GUI()

Func Map_Test_GUI()
    GUICreate("HeroQuest Map Display Tester", 550, 450)
    
    $map_pic = GUICtrlCreatePic("map_grid.jpg", 10, 10, 498, 391)
    $hero_pic = GUICtrlCreatePic("hero.jpg", 31, 35, 17, 17)
    
    GUISetState()
    while 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                Exit
            Case $msg = $hero_pic
                MsgBox(0, "", "Clicked Hero")
        EndSelect
    WEnd
EndFunc

post-5638-1215554004_thumb.jpg

Share this post


Link to post
Share on other sites



Hi,

#include "GuiConstants.au3"

Map_Test_GUI()

Func Map_Test_GUI()
    $hGui = GUICreate("HeroQuest Map Display Tester", 550, 450)
    
    $map_pic = GUICtrlCreatePic("map_grid.jpg", 10, 10, 498, 391)
    $hero_pic = GUICtrlCreatePic("hero.jpg", 31, 35, 17, 17)
    
    GUISetState()
    while 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                Exit
            Case $msg = $map_pic
                $GGCI = GUIGetCursorInfo($hGui)
                If $GGCI[4] = $hero_pic Then
                    MsgBox(0, "", "Clicked Hero")
                Else    
                    MsgBox(0, "", "Clicked Map")
                EndIf   
        EndSelect
    WEnd
EndFunc

Cheers

Share this post


Link to post
Share on other sites

Thank you very much ^^

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