Z-order for Ahk Gui controls? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
PuzzledGreatly
Posts: 1303
Joined: 29 Sep 2013, 22:18

Z-order for Ahk Gui controls?

14 Oct 2020, 17:23

Is there a way to change the order for picture controls in an Ahk Gui? I need to change the zorder depending upon how two picture controls overlap. I know I can have duplicate controls and show or hide them but would prefer to avoid this. Thanks.
User avatar
mikeyww
Posts: 26936
Joined: 09 Sep 2014, 18:38

Re: Zorder for Ahk Gui controls?

14 Oct 2020, 18:00

I'm not sure if this is what you need, but I believe that the order is dictated by the order in which the commands appear in building the GUI.
User avatar
PuzzledGreatly
Posts: 1303
Joined: 29 Sep 2013, 22:18

Re: Zorder for Ahk Gui controls?

14 Oct 2020, 18:21

Thanks mikeyww, yes. What I'm looking for is a way to change this after the GUI is created. It would be good if GuiControl move/movedraw had an option for this.
User avatar
mikeyww
Posts: 26936
Joined: 09 Sep 2014, 18:38

Re: Zorder for Ahk Gui controls?

14 Oct 2020, 18:25

OK. Can't you determine the overlap factor before issuing Gui, Add?
User avatar
PuzzledGreatly
Posts: 1303
Joined: 29 Sep 2013, 22:18

Re: Zorder for Ahk Gui controls?

15 Oct 2020, 01:23

mikeyww wrote:
14 Oct 2020, 18:25
OK. Can't you determine the overlap factor before issuing Gui, Add?
No I can't as one control can be moved around the screen. If there isn't a way to change the zorder on the fly then I'll need duplicate controls and hide/show one depending upon circumstances.
User avatar
SKAN
Posts: 1551
Joined: 29 Sep 2013, 16:58

Re: Z-order for Ahk Gui controls?  Topic is solved

15 Oct 2020, 04:37

PuzzledGreatly wrote:Is there a way to change the order for picture controls in an Ahk Gui?
Use WinSet, Top/Bottom
 
 
image.png
image.png (5.04 KiB) Viewed 646 times
 

Code: Select all

#NoEnv
#Warn
#SingleInstance, Force

Gui, New, HwndhGui -MinimizeBox, Control Z-Order
Gui, Margin, 20, 20
hbm1 := DllCall("CreateBitmap", "Int",1, "Int",1, "Int",0x1, "Int",32, "IntP",0xFF0000, "Ptr")
hbm2 := DllCall("CreateBitmap", "Int",1, "Int",1, "Int",0x1, "Int",32, "IntP",0x00FF00, "Ptr")
hbm3 := DllCall("CreateBitmap", "Int",1, "Int",1, "Int",0x1, "Int",32, "IntP",0x0000FF, "Ptr")

Gui, Add, Picture, xm    ym    w100 h100 hwndhPic1, HBITMAP:%hbm1%
Gui, Add, Picture, xp+24 yp+24 wp   hp   hwndhPic2, HBITMAP:%hbm2%
Gui, Add, Picture, xp+24 yp+24 wp   hp   hwndhPic3, HBITMAP:%hbm3%
ID := {"Red": hPic1, "Green": hPic2, "Blue": hPic3}

Gui, Add, Button, xm  w50 gSetZorder, Red
Gui, Add, Button, x+6 wp  gSetZorder, Green
Gui, Add, Button, x+6 wp  gSetZorder, Blue
Gui, Show
Return

SetZorder:
  WinSet, Bottom,, % "ahk_id" . ID[A_GuiControl]
  WinSet, Redraw,, ahk_id %hGui%
Return
User avatar
mikeyww
Posts: 26936
Joined: 09 Sep 2014, 18:38

Re: Z-order for Ahk Gui controls?

15 Oct 2020, 06:45

Nice! Thank you, @SKAN.
User avatar
PuzzledGreatly
Posts: 1303
Joined: 29 Sep 2013, 22:18

Re: Z-order for Ahk Gui controls?

29 Oct 2020, 19:08

I've been so busy I missed looking at this thread. Thanks very much, SKAN.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: ArkuS, Chunjee, downstairs, Frogrammer, RussF and 349 guests