Jump to content
Sign in to follow this  
smstroble

Who's really OnTop?

Recommended Posts

smstroble

Ok, so im working on a pente game (yet another project to add to my list..), and the pente beads are on the corners of the board grid so unlike my gems game i cannot just check the labels instead of the images in my guiloop, my dilemma is if i set the images OnTop guigetmsg will return the handle's of the clicked pictures but the borders of the labels are drawn overtop of the images and if i set the labels ontop (default) then the images are ontop but clicking on the pictures will return the handle of the label under the click. I really dont want to resort to checking the mouse position, any ideas?

W/ marbles ontop

#include <GUIConstants.au3>

DIM $grid[19][19], $board[19][19], $marbles[19][19], $colors[4]
$colors[0] = "Yellow"
$colors[1] = "Red"
$colors[2] = "Blue"
$colors[3] = "Green"

$boardsize = 600

$mainwnd = GUICreate("Pente", 620, 620)
GUISetBkColor(Dec("FFFFFF"))

For $x = 0 to 17
    For $y = 0 to 17
        $grid[$x][$y] = GUICtrlCreateLabel("", Int(598/18)*$x+12, Int(598/18)*$Y+12, Int(598/18), Int(598/18), $SS_BLACKFRAME)
        
    Next
Next

ProgressOn("Loading", "Loading", "")

$currcol = 0
For $x = 0 to 18
    For $y = 0 to 18
        $marbles[$x][$y] = GUICtrlCreatePic("", Int(598/18)*$x+1, Int(598/18)*$Y+1, 22, 22, $SS_NOTIFY);"marble" & $colors[$currcol] & ".gif", Int(598/18)*$x+1, Int(598/18)*$Y+1, 22, 22)
        ;GUICtrlSetImage($marbles[$x][$y], @ScriptDir & "\marble" & $colors[$currcol] & ".gif")
        GUICtrlSetState(-1, $GUI_ONTOP)
        
        $maintext = "Loading"
        For $i = 1 to $currcol
            $maintext &= "."
        Next
        
        ProgressSet((($x-1)*18+$y)/(18*18)*100, "", $maintext)
        
        $currcol += 1
        If $currcol > 3 Then
            $currcol = 0
        EndIf
        
    Next
Next

ProgressOff()

GUISetState()
mainloop()

Func mainloop()
    While 1 ;gui loop
        $msg = GUIGetMsg()
        ;If $msg > 0 Then
            For $x = 0 to 18
                For $y= 0 to 18
                    If $msg = $marbles[$x][$y] Then
                        MsgBox(0, $x, $y)
                    ElseIf $msg = $grid[$x][$y] And $x <> 18 And $y <> 18 Then
                        MsgBox(0, "Error", $x & "|" & $y)
                    EndIf
                Next
            Next
        ;EndIf
    WEnd
EndFunc
 oÝ÷ Ùh­Vz[:)jëh×6
#include <GUIConstants.au3>

DIM $grid[19][19], $board[19][19], $marbles[19][19], $colors[4]
$colors[0] = "Yellow"
$colors[1] = "Red"
$colors[2] = "Blue"
$colors[3] = "Green"

$boardsize = 600

$mainwnd = GUICreate("Pente", 620, 620)
GUISetBkColor(Dec("FFFFFF"))

For $x = 0 to 17
    For $y = 0 to 17
        $grid[$x][$y] = GUICtrlCreateLabel("", Int(598/18)*$x+12, Int(598/18)*$Y+12, Int(598/18), Int(598/18), $SS_BLACKFRAME)
        
    Next
Next

ProgressOn("Loading", "Loading", "")

$currcol = 0
For $x = 0 to 18
    For $y = 0 to 18
        $marbles[$x][$y] = GUICtrlCreatePic("", Int(598/18)*$x+1, Int(598/18)*$Y+1, 22, 22, $SS_NOTIFY);"marble" & $colors[$currcol] & ".gif", Int(598/18)*$x+1, Int(598/18)*$Y+1, 22, 22)
        ;GUICtrlSetImage($marbles[$x][$y], @ScriptDir & "\marble" & $colors[$currcol] & ".gif")
        ;GUICtrlSetState(-1, $GUI_ONTOP)
        
        $maintext = "Loading"
        For $i = 1 to $currcol
            $maintext &= "."
        Next
        
        ProgressSet((($x-1)*18+$y)/(18*18)*100, "", $maintext)
        
        $currcol += 1
        If $currcol > 3 Then
            $currcol = 0
        EndIf
        
    Next
Next

ProgressOff()

GUISetState()
mainloop()

Func mainloop()
    While 1 ;gui loop
        $msg = GUIGetMsg()
        ;If $msg > 0 Then
            For $x = 0 to 18
                For $y= 0 to 18
                    If $msg = $marbles[$x][$y] Then
                        MsgBox(0, $x, $y)
                    ElseIf $msg = $grid[$x][$y] And $x <> 18 And $y <> 18 Then
                        MsgBox(0, "Error", $x & "|" & $y)
                    EndIf
                Next
            Next
        ;EndIf
    WEnd
EndFunc

EDIT: Fixed code to work w/o pics

Edited by smstroble

MUHAHAHAHAHA

Share this post


Link to post
Share on other sites
smstroble

Ok, i fixed the problem my disableing the labels, still think its stange that the rendering layers backwards.


MUHAHAHAHAHA

Share this post


Link to post
Share on other sites
smstroble

Interesting, so correct me if I'm wrong, you created labels ontop of the upperbuttons and made them invisible so that they can have topmost control w/o being displayed wrong and finagled with the other buttons to get them to be displayed correctly reguardless of control order? I think that makes sense lol, I'll try it said idea out tonight when i get a chance.


MUHAHAHAHAHA

Share this post


Link to post
Share on other sites
Valuater

Interesting, so correct me if I'm wrong, you created labels ontop of the upperbuttons and made them invisible so that they can have topmost control w/o being displayed wrong and finagled with the other buttons to get them to be displayed correctly reguardless of control order? I think that makes sense lol, I'll try it said idea out tonight when i get a chance.

Kinda...???!!! ...lol

good luck on that

8)


NEWHeader1.png

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  

×