Page 1 of 1

Z-order for Ahk Gui controls?

Posted: 14 Oct 2020, 17:23
by PuzzledGreatly
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.

Re: Zorder for Ahk Gui controls?

Posted: 14 Oct 2020, 18:00
by mikeyww
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.

Re: Zorder for Ahk Gui controls?

Posted: 14 Oct 2020, 18:21
by PuzzledGreatly
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.

Re: Zorder for Ahk Gui controls?

Posted: 14 Oct 2020, 18:25
by mikeyww
OK. Can't you determine the overlap factor before issuing Gui, Add?

Re: Zorder for Ahk Gui controls?

Posted: 15 Oct 2020, 01:23
by PuzzledGreatly
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.

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

Posted: 15 Oct 2020, 04:37
by SKAN
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 146 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

Re: Z-order for Ahk Gui controls?

Posted: 15 Oct 2020, 06:45
by mikeyww
Nice! Thank you, @SKAN.

Re: Z-order for Ahk Gui controls?

Posted: 15 Oct 2020, 13:41
by SKAN
@mikeyww :thumbup: :)

Re: Z-order for Ahk Gui controls?

Posted: 29 Oct 2020, 19:08
by PuzzledGreatly
I've been so busy I missed looking at this thread. Thanks very much, SKAN.