Sign in to follow this  
Followers 0
iAmNewbe

Is it possible to set Z position of GUI Controls ?

6 posts in this topic

Wondering if it is possible to set the Z position of a GUI Control specifically the Pic Control  "GUCtrlCreatePic"

Looking at GUICtrlSetPos and GUICtrlSetResizing I don't see a way to do it.

I am animating BMP pictures inside of a GUI window but they need to move underneath existing controls such as buttons and labels I have in the GUI.

An example to give you a mental picture for this would be an Image gallery that moves from left to right across the screen  but the image is only visible within a box in the center of the GUI window.  In Flash animations back when I was creating those you had a stage where you could layout images off screen lined up next to each other and you had a layer sitting on top of the main visible stage that hid the images except for the area you specifically wanted to show them.  I wanted to do something similar here but I also have Label and Button controls in the way which the images would need to be underneath.

Suggestions?

 

 

Share this post


Link to post
Share on other sites



Ok,  I found this      GUICtrlSetState($HID, $GUI_ONTOP)

If there were a way to set this to  $GUI_ONBOTTOM  or a specific Z index that would be better...  Playing with it.

1 person likes this

Share this post


Link to post
Share on other sites

Apparently each control you set the state to  $GUI_ONTOP sits on top of the control below it. You can stack z-order by choosing the order you set  $GUI_ONTOP for each control.  Nice.

Share this post


Link to post
Share on other sites

I set a a couple of nested loops to run the images across the screen and set each image  1, 2 ,3 etc...  so 2 sits on top of 1 then 3 sits on top of 2 and they move across the screen doing sort of a stacked playing card thing.  Interesting playing with these functions..   

Share this post


Link to post
Share on other sites

Might be interesting to post the code as a demo for people to try.

1 person likes this

Share this post


Link to post
Share on other sites

Ok. here is some sample code that illustrates z-index of images moving across the screen.

It's somewhat different than the code I was using in my project but I tested this and it works. Images do flicker but I was more interested in seeing if I could do this especially with z-index. This works for controls too not just images so you can z-index labels or whatever.  

All this does is stack 3 images, which you have to supply yourself, on top of each other similar to playing cards and moves them across the gui then turns them around and moves them back to the beginning point. I used an array to hold the location of the images for easy updating.

 

#include <GUIConstantsEx.au3>
#include <Array.au3>
#cs
    Testing moving images stacked on top of each other across a gui window
    You need to supply your own images 93 pixels wide and 93 pixels in height
    or make adjustments to the dimensions in the code.
#ce

HotKeySet("{ESC}", "appClose")
Local $images[3]  = [ "Images\img1.bmp",  "Images\img2.bmp", "Images\img3.bmp" ] ; Update this with the location of your images in BMP or JPG formats
createGUI($images)

Func createGUI($images)
    Global $app = GUICreate("", 500, 150,( @DesktopWidth - 500 ) / 2,  ( @DesktopHeight / 2 ) - 150)  ; Width, Height, Horizontal, Vertical
    Global $pic1 = GUICtrlCreatePic($images[0], 50, 30, 93, 93)
    GUICtrlSetState(-1, $GUI_ONTOP)
    Global $pic2 = GUICtrlCreatePic($images[1], 100, 30, 93, 93)
    GUICtrlSetState(-1, $GUI_ONTOP)
    Global $pic3 = GUICtrlCreatePic($images[2], 150, 30, 93, 93)
    GUICtrlSetState(-1, $GUI_ONTOP)
    GUISetState(@SW_SHOW)
    moveImagesForward()
EndFunc

Func moveImagesForward()
    Dim $pic1, $pic2, $pic3
    Local $b = 0
    While $b <= 240
        GUICtrlSetPos($pic3, $b, 30, 93, 93)
        GUICtrlSetPos($pic2, $b+70, 30, 93, 93)
        GUICtrlSetPos($pic1, $b+120, 30, 93, 93)
        $b = $b +5
        Sleep(25)
    WEnd
    moveImagesBackwards()
EndFunc

Func moveImagesBackwards()
    Dim $pic1, $pic2, $pic3
    Local $b = 400
    While $b >= 150
        GUICtrlSetPos($pic3, $b, 30, 93, 93)
        GUICtrlSetPos($pic2, $b-70, 30, 93, 93)
        GUICtrlSetPos($pic1, $b-120, 30, 93, 93)
        $b = $b - 5
        Sleep(25)
    WEnd
EndFunc

Func appClose()
        Exit
EndFunc

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            appClose()
    EndSwitch
WEnd

 

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