Child gui is always behind Parent gui Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
kyuuuri
Posts: 340
Joined: 09 Jan 2016, 19:20

Child gui is always behind Parent gui

01 Apr 2020, 12:01

Introduction
Hello, I've been trying to get this script to work but the child gui is ALWAYS behind the parent gui.
I'm testing this script on both w10 and w7, both 64 bits with latest version of ahk.

Code

Code: Select all

Gui, background:New, +hwndhParent
Gui, background:Add, Picture, x0 y0 h250 w250, website.jpg

Gui, child: New, +Parentbackground +HWNDhChild1 -0x80000000 +0x40000000 +E0x00010000
Gui, child: Add, Picture, x5 y5 w500 h500, Moon.jpg
Gui, child: -Caption
gui, child: Show, x18 y17
gui, background: show, x0 y0 h500 w500, testBug
Moon:
Image

Panda:
Image

Expected behaviour
The moon should be on top of the panda. (Child on top of Parent)

Current behaviour
The panda is on top of the moon. (Parent on top of child)

What I tried
I tried changing the order of the gui commands but still, nothing worked.


Hope you can help me, thanks in advance.
Last edited by kyuuuri on 01 Apr 2020, 12:17, edited 1 time in total.
User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: Child gui is always behind Parent gui

01 Apr 2020, 12:09

See if this works for you.

Code: Select all

#SingleInstance, Force
#NoEnv
SetBatchLines, -1

Gui,1:+AlwaysOnTop

Gui,2:+Parent1
Gui,2:Color,Black
Gui,2:Show,x0 y0 w100 h100

Gui,1:Show,w200 h200

return
GuiClose:
GuiContextMenu:
*ESC::
	ExitApp
kyuuuri
Posts: 340
Joined: 09 Jan 2016, 19:20

Re: Child gui is always behind Parent gui

01 Apr 2020, 12:13

Hellbent wrote:
01 Apr 2020, 12:09
See if this works for you.

Code: Select all

#SingleInstance, Force
#NoEnv
SetBatchLines, -1

Gui,1:+AlwaysOnTop

Gui,2:+Parent1
Gui,2:Color,Black
Gui,2:Show,x0 y0 w100 h100

Gui,1:Show,w200 h200

return
GuiClose:
GuiContextMenu:
*ESC::
	ExitApp
Nop, I don't want the parent gui to be always on top. Also the child gui is still behind the parent gui.
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: Child gui is always behind Parent gui

01 Apr 2020, 12:29

If you want the reversed result, why not reverse the parent/child relationship? Disclaimer, I don't even remember what is parent/child relation.
Cheers.
kyuuuri
Posts: 340
Joined: 09 Jan 2016, 19:20

Re: Child gui is always behind Parent gui

01 Apr 2020, 12:33

Helgef wrote:
01 Apr 2020, 12:29
If you want the reversed result, why not reverse the parent/child relationship? Disclaimer, I don't even remember what is parent/child relation.
Cheers.
Because that won't behave as expected. I need the parent gui to be the parent and the child to be the child.
This parent gui will have a lot of childs and I can't reverse the child parent thing.
There are features that I need, for example when moving the parent gui, the child will move with it.
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: Child gui is always behind Parent gui

01 Apr 2020, 12:35

We'll have to wait for the gui-gurus to save the day then ;)

Cheers.
User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: Child gui is always behind Parent gui

01 Apr 2020, 12:37

Moving the parent Pic control after the 2nd window is created seems to make a difference for me.

Code: Select all

Gui, background:New, +hwndhParent
Gui, child: New, +Parentbackground +HWNDhChild1 -0x80000000 +0x40000000 +E0x00010000
Gui, child: Add, Picture, x5 y5 w500 h500 BackgroundTrans, website.jpg
Gui, child: -Caption
gui, child: Show, x18 y17
gui, background: show, x0 y0 h500 w500, testBug
Gui, background:Add, Picture, x0 y0 h250 w250 BackgroundTrans, Moon.jpg
Spoiler
Last edited by Hellbent on 01 Apr 2020, 13:55, edited 1 time in total.
User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: Child gui is always behind Parent gui

01 Apr 2020, 12:56

If having the child window show transparency is something you want, you may want to consider using a Layered Window. Similar to this, but yours would only require 1 layered window whereas this one uses 3.

Code: Select all

;***************************************************************************************************
;***************************************************************************************************
;***************************************************************************************************
#Include <My Altered Gdip Lib>  ;<------       Replace with your copy of GDIP
;***************************************************************************************************
;***************************************************************************************************
;***************************************************************************************************
#SingleInstance, Force
SetBatchLines, -1


BGMain := New LayeredWindow( x := "" , y := "" , w := 300 , h := 200 , window := 1 , title := "Toggle Clicker v2" , smoothing := 2 , options := "+AlwaysOnTop -DPIScale" , autoShow := 1 , GdipStart := 1 , WinMover := "" , BackgroundColor := "" )
BBrush := Gdip_BrushCreateSolid( "0xFF880000" ), BPen := Gdip_CreatePen( "0xFF555555" , 1 ), BP := []

Loop, 50
	BP.Push({X:Ran(-10,300),Y:Ran(-10,200),W:Ran(5,30),Phase:Ran(0,1),Co:Ran(0,3),Max: Max:=Ran(10,50),Min:Ran(3,Max)})


pBanner := BannerTag("Wash Your Hands" )
BannerWin := New LayeredWindow( x := 30 , y := 0 , w := 240 , h := 40 , window := 2 , title := " " , smoothing := 2 , options := "-DPIScale +Parent1" , autoShow := 1 , GdipStart := 0 , WinMover := "" , BackgroundColor := "" )
Banner := {Bitmap1:BannerTag("Wash Your Hands"),Bitmap2:BannerTag("HB Toggle Clicker"),X:20,Y:0,W:160,H:30,Dir1:1,Dir2:1,PhaseCo:0,Phase:1}
Gdip_DrawImage(BannerWin.G, Banner.Bitmap2, Banner.X, Banner.Y, Banner.W, Banner.H) 
BannerWin.UpdateWindow()
Bit:=Banner.Bitmap2
Gui,2:Add,Text,x0 y0 w300 h30 BackgroundTrans gMoveWin


InnerWin1 := New LayeredWindow( x := 10 , y := 40 , w := 280 , h := 150 , window := 3 , title := " " , smoothing := 2 , options := "-DPIScale +Parent1" , autoShow := 1 , GdipStart := 0 , WinMover := "" , BackgroundColor := "0x22000000" )
INPen1 := Gdip_CreatePen( "0xFF440000" , 1 )
Gdip_DrawRectangle(InnerWin1.G, INPen1,0, 0, InnerWin1.W-1, InnerWin1.H-1)
Gdip_DrawImage(InnerWin1.G, TogClButtSet1(), 0, 0, InnerWin1.W, InnerWin1.H) 
InnerWin1.UpdateWindow()

Butts := []
Gui,3:Add,Text,x30 y35 w220 h30 BackgroundTrans hwndhwnd gHotkeysWindow
Butts[hwnd]:=1
Gui,3:Add,Text,x30 y75 w220 h30 BackgroundTrans hwndhwnd gClickSpeedWindow
Butts[hwnd]:=2
Gui,3:Add,Text,x30 y115 w220 h30 BackgroundTrans hwndhwnd gMoreOptionsWindow
Butts[hwnd]:=3

SetTimer, Hover, 50
SetTimer, BannerM, 50
SetTimer, Ani, 100
return
GuiClose:
GuiContextMenu:
*ESC::
	ExitApp
Ran(Min,Max){
	Random, Out, Min, Max
	return Out
}

Hover:
	MouseGetPos,,,,ctrl,2
	if(Butts[ctrl]&&!Active){
		LCtrl := ctrl
		InnerWin1.ClearWindow()
		Gdip_DrawImage(InnerWin1.G, WiniBit := TogClButtSet1(Active := Butts[ctrl]), 0, 0, InnerWin1.W, InnerWin1.H) 
		Gdip_DrawRectangle(InnerWin1.G, INPen1,0, 0, InnerWin1.W-1, InnerWin1.H-1)
		InnerWin1.UpdateWindow()
		Gdip_DisposeImage( WiniBit )
	}else if(Butts[LCtrl]!=Butts[ctrl]&&Active){
		InnerWin1.ClearWindow()
		Gdip_DrawImage(InnerWin1.G, WiniBit := TogClButtSet1(Active := 0), 0, 0, InnerWin1.W, InnerWin1.H) 
		Gdip_DrawRectangle(InnerWin1.G, INPen1,0, 0, InnerWin1.W-1, InnerWin1.H-1)
		InnerWin1.UpdateWindow()
		Gdip_DisposeImage( WiniBit )
	}
	return

MoveWin:
	PostMessage, 0xA1, 2,,,Toggle Clicker v2
	return

HotkeysWindow:
	ToolTip, here in hotkeys
	return

ClickSpeedWindow:
	ToolTip, here in Click Speed
	return

MoreOptionsWindow:
	ToolTip, here in Options
	return
	
BannerM:
	(Banner.Dir1=1&&Banner.X>=10)?(Banner.X-=2):(Banner.Dir1=1&&Banner.X<10)?(Banner.Dir1:=2)
	(Banner.Dir1=2&&Banner.X<=70)?(Banner.X+=3):(Banner.Dir1=2&&Banner.X>70)?(Banner.Dir1:=1)
	
	(Banner.Dir2=1&&Banner.Y<=10)?(Banner.Y+=.3):(Banner.Dir2=1&&Banner.Y>10)?(Banner.Dir2:=2)
	(Banner.Dir2=2&&Banner.Y>=2)?(Banner.Y-=.3):(Banner.Dir2=2&&Banner.Y<2)?(Banner.Dir2:=1)
	(++Banner.PhaseCo>30)?(Banner.PhaseCo:=0,(Banner.Phase=1)?(Bit:=Banner.Bitmap2,Banner.Phase:=2):(Bit:=Banner.Bitmap1,Banner.Phase:=1))
	
	BannerWin.ClearWindow()
	Gdip_DrawImage(BannerWin.G, Bit, Banner.X, Banner.Y, Banner.W, Banner.H)
	BannerWin.UpdateWindow()
	return
	
Ani:
	;~ BGMain.ClearWindow()
	BGMain.PaintBackground( BackgroundColor := "0x19171719" )
	;~ BGMain.PaintBackground( BackgroundColor := "0xff171719" )
	loop, % BP.Length(){
		(BP[A_Index].Phase=1&&BP[A_Index].W<BP[A_Index].Min)?(BP[A_Index].Phase := 0):(BP[A_Index].Phase=0&&BP[A_Index].W>BP[A_Index].Max)?(BP[A_Index].Phase := 1 , BP[A_Index].Co += 1)
		(BP[A_Index].Phase=1)?(BP[A_Index].X += 1,BP[A_Index].Y += 1,BP[A_Index].W -= 2,BP[A_Index].H -= 2):(BP[A_Index].X -= 1,BP[A_Index].Y -= 1,BP[A_Index].W += 2,BP[A_Index].H += 2)
		(BP[A_Index].Co>4)?(BP[A_Index] := {X:Ran(-10,300),Y:Ran(-10,200),W:Ran(5,30),Phase:Ran(0,1),Co:Ran(0,3),Max: Max:=Ran(10,50),Min:Ran(3,Max)})
		;~ Brush3 := Gdip_CreateLineBrushFromRect( BP[A_Index].x, BP[A_Index].y, BP[A_Index].w, BP[A_Index].w , "0x77660000" , "0xff000000" , 1 , 1 )
		Brush3 := Gdip_CreateLineBrushFromRect( BP[A_Index].x, BP[A_Index].y, BP[A_Index].w, BP[A_Index].w , "0xff660000" , "0xff000000" , 1 , 1 )
		Gdip_FillEllipse(BGMain.G, Brush3, BP[A_Index].x, BP[A_Index].y, BP[A_Index].w, BP[A_Index].w)
		Gdip_DeleteBrush( Brush3 )
		Gdip_DrawRectangle(BGMain.G, BPen,0, 0, 299, 199)

	}
	BGMain.UpdateWindow()
	return





;######################################################################################################################################################################################
;######################################################################################################################################################################################
;######################################################################################################################################################################################
class LayeredWindow	{
	__New( x := 0 , y := 0 , w := 100 , h := 100 , window := 1 , title := " " , smoothing := 4 , options := "" , autoShow := 1 , GdipStart := 0 , WinMover := "" , BackgroundColor := "" ){
		This.X := x , This.Y := y , This.W := w , This.H := h , This.Window := window , This.Title := title , This.Options := options , This.Smoothing := smoothing
		( GdipStart ) ? ( This.Token := Gdip_Startup() )
		This._CreateWindow()
		( autoShow ) ? ( This.ShowWindow() )
		This._SetUpdateLayeredWindow()
		( WinMover ) ? ( This._AddMoveTrigger( WinMover ) )
		( BackgroundColor ) ? ( This.PaintBackground( BackgroundColor , 1 ) )
	}_CreateWindow(){
		Gui , % This.Window ": New" , % " +E0x80000 +LastFound -Caption " This.Options 
		This.Hwnd := WinExist()
		This.hbm := CreateDIBSection( This.W , This.H )
		This.hdc := CreateCompatibleDC()
		This.obm := SelectObject( This.hdc , This.hbm )
		This.G := Gdip_GraphicsFromHDC( This.hdc )
		Gdip_SetSmoothingMode( This.G , This.Smoothing )
	}_SetUpdateLayeredWindow(){
		UpdateLayeredWindow( This.hwnd , This.hdc , This.X , This.Y , This.W , This.H )
	}UpdateWindow(){
		UpdateLayeredWindow( This.hwnd , This.hdc )
	}ShowWindow( update := 1 , Position := "" ){ 
		if( !Position )
			Gui , % This.Window ": Show" , % "w" This.W " h" This.H  , % ( This.Title ) ? ( This.Title ) : ( "" )
		else
			Gui , % This.Window ": Show" , % "x" Position.X " y" Position.Y "w" Position.W " h" Position.H  , % ( This.Title ) ? ( This.Title )  : ( "" )
		( update ) ? ( This.UpdateWindow() )
	}_AddMoveTrigger( positons ){ 
		local hwnd , bd
		Gui , % This.Window " : Add" , Text , % "x" positons.x " y" positons.y " w" positons.w " h" positons.h " hwndhwnd BackgroundTrans"
		This.MoveHwnd := hwnd
		bd := This._WindowMover.Bind( This )
		GuiControl , % This.Window ": +G" , % This.MoveHwnd , % bd
	}_WindowMover(){ 
		PostMessage, 0xA1 , 2
	}PaintBackground( BackgroundColor := "0xFF000000" , update := 0){ 
		local Brush
		This.BackgroundColor := BackgroundColor
		Brush := Gdip_BrushCreateSolid( BackgroundColor )
		Gdip_FillRectangle( This.G , Brush , 0 , 0 , This.W , This.H )
		Gdip_DeleteBrush( Brush )
		( update ) ? ( This.UpdateWindow() )
	}Draw( pBitmap , Positions := "" , update := 1 , disposeBitmap := 0  , PaintBackground := 0){ 
		(PaintBackground) ? ( This.PaintBackground( This.BackgroundColor ) )	
		Gdip_DrawImage( This.G , pBitmap , ( Positions.X1 ) ? ( Positions.X1 ) : ( Positions.X ) ? ( Positions.X ) : ( "" ) , ( Positions.Y1 ) ? ( Positions.Y1 ) : ( Positions.Y ) ? ( Positions.Y ) : ( "" ) , ( Positions.W1 ) ? ( Positions.W1 ) : ( Positions.W ) ? ( Positions.W ) : ( "" ) , ( Positions.H1 ) ? ( Positions.H1 ) : ( Positions.H ) ? ( Positions.H ) : ( "" ) , ( Positions.X2 ) ? ( Positions.X2 ) : ( Positions.SX ) ? ( Positions.SX ) : ( "" ) , ( Positions.Y2 ) ? ( Positions.Y2 ) : ( Positions.SY ) ? ( Positions.SY ) : ( "" ) , ( Positions.W2 ) ? ( Positions.W2 ) : ( Positions.SW ) ? ( Positions.SW ) : ( "" ) , ( Positions.H2 ) ? ( Positions.H2 ) : ( Positions.SH ) ? ( Positions.SH ) : ( "" ) )
		( update ) ? ( This.UpdateWindow() )
		( disposeBitmap ) ? ( Gdip_DisposeImage( pBitmap ) )
	}ClearWindow( update := "" ){ 
		Gdip_GraphicsClear( This.G )
		( update ) ? ( This.UpdateWindow() )
	}DeleteWindow( TurnOffGdip := 0 ){
		SelectObject( This.hdc , This.obm ) , DeleteObject( This.hbm ) , DeleteDC( This.hdc ) , Gdip_DeleteGraphics( This.G )
		( TurnOffGdip && This.Token ) ? ( Gdip_Shutdown( This.Token ) )
		Gui, % This.Window " : Destroy"
	}
}



BannerTag(txt := "Wash Your Hands" ){
	;Bitmap Created Using: HB Bitmap Maker
	pBitmap:=Gdip_CreateBitmap( 160 , 30 ),G := Gdip_GraphicsFromImage( pBitmap ),Gdip_SetSmoothingMode( G , 2 )
	Brush := Gdip_BrushCreateSolid( "0xFF888888" )
	Gdip_FillRoundedRectangle( G , Brush , 1 , 2 , 157 , 26 , 4 )
	Gdip_DeleteBrush( Brush )
	;~ Brush := Gdip_BrushCreateSolid( "0xFF333333" )
	Brush := Gdip_BrushCreateSolid( "0xFF171719" )
	Gdip_FillRoundedRectangle( G , Brush , 2 , 3 , 155 , 24 , 3 )
	Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( "0xFFaaaaaa" )
	Gdip_TextToGraphics( G , txt , "s16 Center vCenter Bold c" Brush " x-1 y0" , "Segoe ui" , 160 , 30 )
	Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( "0xFF770000" )
	Gdip_TextToGraphics( G , txt , "s16 Center vCenter Bold c" Brush " x0 y1" , "Segoe ui" , 160 , 30 )
	Gdip_DeleteBrush( Brush )
	Gdip_DeleteGraphics( G )
	return pBitmap
}

TogClButtSet1(value:=0){
	;Bitmap Created Using: HB Bitmap Maker
	pBitmap:=Gdip_CreateBitmap( 280 , 150 ) 
	G := Gdip_GraphicsFromImage( pBitmap )
	Gdip_SetSmoothingMode( G , 2 )
	;Hotkeys
	Brush := Gdip_CreateLineBrushFromRect( 29 , 36 , 221 , 28 , (Value=1)?("0xFFaa0000"):("0xFF880000")  , "0xFF000000" , 1 , 1 )
	Gdip_FillRoundedRectangle( G , Brush , 30 , 35 , 220 , 30 , 5 )
	Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( (Value=1)?("0x44000000"):("0x44222222") )
	Gdip_FillRoundedRectangle( G , Brush , 31 , 36 , 218 , 28 , 4 )
	Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( "0xFF777777" )
	Gdip_TextToGraphics( G , "Hotkeys" , "s16 Center vCenter Bold c" Brush " x30 y35" , "Segoe ui" , 218 , 28 )
	Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrushFromRect( 109 , 38 , 72 , 14 , (Value=1)?("0xFF000000"):("0xFF880000") , (Value=1)?("0xFF880000"):("0xFF000000") , 1 , 1 )
	Gdip_TextToGraphics( G , "Hotkeys" , "s16 Center vCenter Bold c" Brush " x31 y36" , "Segoe ui" , 218 , 28 )
	Gdip_DeleteBrush( Brush )
	;Click Speed
	Brush := Gdip_CreateLineBrushFromRect( 30 , 74 , 219 , 29 ,(Value=2)?("0xFFaa0000"):("0xFF880000") , "0xFF000000" , 1 , 1 )
	Gdip_FillRoundedRectangle( G , Brush , 30 , 75 , 220 , 30 , 4 )
	Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( (Value=2)?("0x44000000"):("0x44222222") )
	Gdip_FillRoundedRectangle( G , Brush , 31 , 76 , 218 , 28 , 4 )
	Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( "0xFF777777" )
	Gdip_TextToGraphics( G , "Click Speed" , "s16 Center vCenter Bold c" Brush " x30 y75" , "Segoe ui" , 218 , 28 )
	Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrushFromRect( 92 , 77 , 94 , 17 ,(Value=2)?("0xFF000000"):("0xFF880000") ,(Value=2)?("0xFF880000"):("0xFF000000") , 1 , 1 )
	Gdip_TextToGraphics( G , "Click Speed" , "s16 Center vCenter Bold c" Brush " x31 y76" , "Segoe ui" , 218 , 28 )
	Gdip_DeleteBrush( Brush )
	;More Options
	Brush := Gdip_CreateLineBrushFromRect( 31 , 115 , 216 , 27 ,(Value=3)?("0xFFaa0000"):("0xFF880000") , "0xFF000000" , 1 , 1 )
	Gdip_FillRoundedRectangle( G , Brush , 30 , 115 , 220 , 30 , 4 )
	Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( (Value=3)?("0x44000000"):("0x44222222") )
	Gdip_FillRoundedRectangle( G , Brush , 31 , 116 , 218 , 28 , 4 )
	Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( "0xFF777777" )
	Gdip_TextToGraphics( G , "More Options" , "s16 Center vCenter Bold c" Brush " x30 y115" , "Segoe ui" , 218 , 28 )
	Gdip_DeleteBrush( Brush )
	if(Value=3)
		Brush := Gdip_CreateLineBrushFromRect( 87 , 116 , 105 , 18 , "0xFF000000" , "0xFF880000" , 1 , 1 )
	else
		Brush := Gdip_CreateLineBrushFromRect( 87 , 116 , 105 , 18 , "0xFF880000" , "0xFF000000" , 1 , 1 )
	Gdip_TextToGraphics( G , "More Options" , "s16 Center vCenter Bold c" Brush " x31 y116" , "Segoe ui" , 218 , 28 )
	Gdip_DeleteBrush( Brush )
	Gdip_DeleteGraphics( G )
	return pBitmap 
}
^ Requires Windows 8+ ^
kyuuuri
Posts: 340
Joined: 09 Jan 2016, 19:20

Re: Child gui is always behind Parent gui

01 Apr 2020, 13:54

Hellbent wrote:
01 Apr 2020, 12:56
If having the child window show transparency is something you want, you may want to consider using a Layered Window. Similar to this, but yours would only require 1 layered window whereas this one uses 3.

Code: Select all

;***************************************************************************************************
;***************************************************************************************************
;***************************************************************************************************
#Include <My Altered Gdip Lib>  ;<------       Replace with your copy of GDIP
;***************************************************************************************************
;***************************************************************************************************
;***************************************************************************************************
#SingleInstance, Force
SetBatchLines, -1


BGMain := New LayeredWindow( x := "" , y := "" , w := 300 , h := 200 , window := 1 , title := "Toggle Clicker v2" , smoothing := 2 , options := "+AlwaysOnTop -DPIScale" , autoShow := 1 , GdipStart := 1 , WinMover := "" , BackgroundColor := "" )
BBrush := Gdip_BrushCreateSolid( "0xFF880000" ), BPen := Gdip_CreatePen( "0xFF555555" , 1 ), BP := []

Loop, 50
	BP.Push({X:Ran(-10,300),Y:Ran(-10,200),W:Ran(5,30),Phase:Ran(0,1),Co:Ran(0,3),Max: Max:=Ran(10,50),Min:Ran(3,Max)})


pBanner := BannerTag("Wash Your Hands" )
BannerWin := New LayeredWindow( x := 30 , y := 0 , w := 240 , h := 40 , window := 2 , title := " " , smoothing := 2 , options := "-DPIScale +Parent1" , autoShow := 1 , GdipStart := 0 , WinMover := "" , BackgroundColor := "" )
Banner := {Bitmap1:BannerTag("Wash Your Hands"),Bitmap2:BannerTag("HB Toggle Clicker"),X:20,Y:0,W:160,H:30,Dir1:1,Dir2:1,PhaseCo:0,Phase:1}
Gdip_DrawImage(BannerWin.G, Banner.Bitmap2, Banner.X, Banner.Y, Banner.W, Banner.H) 
BannerWin.UpdateWindow()
Bit:=Banner.Bitmap2
Gui,2:Add,Text,x0 y0 w300 h30 BackgroundTrans gMoveWin


InnerWin1 := New LayeredWindow( x := 10 , y := 40 , w := 280 , h := 150 , window := 3 , title := " " , smoothing := 2 , options := "-DPIScale +Parent1" , autoShow := 1 , GdipStart := 0 , WinMover := "" , BackgroundColor := "0x22000000" )
INPen1 := Gdip_CreatePen( "0xFF440000" , 1 )
Gdip_DrawRectangle(InnerWin1.G, INPen1,0, 0, InnerWin1.W-1, InnerWin1.H-1)
Gdip_DrawImage(InnerWin1.G, TogClButtSet1(), 0, 0, InnerWin1.W, InnerWin1.H) 
InnerWin1.UpdateWindow()

Butts := []
Gui,3:Add,Text,x30 y35 w220 h30 BackgroundTrans hwndhwnd gHotkeysWindow
Butts[hwnd]:=1
Gui,3:Add,Text,x30 y75 w220 h30 BackgroundTrans hwndhwnd gClickSpeedWindow
Butts[hwnd]:=2
Gui,3:Add,Text,x30 y115 w220 h30 BackgroundTrans hwndhwnd gMoreOptionsWindow
Butts[hwnd]:=3

SetTimer, Hover, 50
SetTimer, BannerM, 50
SetTimer, Ani, 100
return
GuiClose:
GuiContextMenu:
*ESC::
	ExitApp
Ran(Min,Max){
	Random, Out, Min, Max
	return Out
}

Hover:
	MouseGetPos,,,,ctrl,2
	if(Butts[ctrl]&&!Active){
		LCtrl := ctrl
		InnerWin1.ClearWindow()
		Gdip_DrawImage(InnerWin1.G, WiniBit := TogClButtSet1(Active := Butts[ctrl]), 0, 0, InnerWin1.W, InnerWin1.H) 
		Gdip_DrawRectangle(InnerWin1.G, INPen1,0, 0, InnerWin1.W-1, InnerWin1.H-1)
		InnerWin1.UpdateWindow()
		Gdip_DisposeImage( WiniBit )
	}else if(Butts[LCtrl]!=Butts[ctrl]&&Active){
		InnerWin1.ClearWindow()
		Gdip_DrawImage(InnerWin1.G, WiniBit := TogClButtSet1(Active := 0), 0, 0, InnerWin1.W, InnerWin1.H) 
		Gdip_DrawRectangle(InnerWin1.G, INPen1,0, 0, InnerWin1.W-1, InnerWin1.H-1)
		InnerWin1.UpdateWindow()
		Gdip_DisposeImage( WiniBit )
	}
	return

MoveWin:
	PostMessage, 0xA1, 2,,,Toggle Clicker v2
	return

HotkeysWindow:
	ToolTip, here in hotkeys
	return

ClickSpeedWindow:
	ToolTip, here in Click Speed
	return

MoreOptionsWindow:
	ToolTip, here in Options
	return
	
BannerM:
	(Banner.Dir1=1&&Banner.X>=10)?(Banner.X-=2):(Banner.Dir1=1&&Banner.X<10)?(Banner.Dir1:=2)
	(Banner.Dir1=2&&Banner.X<=70)?(Banner.X+=3):(Banner.Dir1=2&&Banner.X>70)?(Banner.Dir1:=1)
	
	(Banner.Dir2=1&&Banner.Y<=10)?(Banner.Y+=.3):(Banner.Dir2=1&&Banner.Y>10)?(Banner.Dir2:=2)
	(Banner.Dir2=2&&Banner.Y>=2)?(Banner.Y-=.3):(Banner.Dir2=2&&Banner.Y<2)?(Banner.Dir2:=1)
	(++Banner.PhaseCo>30)?(Banner.PhaseCo:=0,(Banner.Phase=1)?(Bit:=Banner.Bitmap2,Banner.Phase:=2):(Bit:=Banner.Bitmap1,Banner.Phase:=1))
	
	BannerWin.ClearWindow()
	Gdip_DrawImage(BannerWin.G, Bit, Banner.X, Banner.Y, Banner.W, Banner.H)
	BannerWin.UpdateWindow()
	return
	
Ani:
	;~ BGMain.ClearWindow()
	BGMain.PaintBackground( BackgroundColor := "0x19171719" )
	;~ BGMain.PaintBackground( BackgroundColor := "0xff171719" )
	loop, % BP.Length(){
		(BP[A_Index].Phase=1&&BP[A_Index].W<BP[A_Index].Min)?(BP[A_Index].Phase := 0):(BP[A_Index].Phase=0&&BP[A_Index].W>BP[A_Index].Max)?(BP[A_Index].Phase := 1 , BP[A_Index].Co += 1)
		(BP[A_Index].Phase=1)?(BP[A_Index].X += 1,BP[A_Index].Y += 1,BP[A_Index].W -= 2,BP[A_Index].H -= 2):(BP[A_Index].X -= 1,BP[A_Index].Y -= 1,BP[A_Index].W += 2,BP[A_Index].H += 2)
		(BP[A_Index].Co>4)?(BP[A_Index] := {X:Ran(-10,300),Y:Ran(-10,200),W:Ran(5,30),Phase:Ran(0,1),Co:Ran(0,3),Max: Max:=Ran(10,50),Min:Ran(3,Max)})
		;~ Brush3 := Gdip_CreateLineBrushFromRect( BP[A_Index].x, BP[A_Index].y, BP[A_Index].w, BP[A_Index].w , "0x77660000" , "0xff000000" , 1 , 1 )
		Brush3 := Gdip_CreateLineBrushFromRect( BP[A_Index].x, BP[A_Index].y, BP[A_Index].w, BP[A_Index].w , "0xff660000" , "0xff000000" , 1 , 1 )
		Gdip_FillEllipse(BGMain.G, Brush3, BP[A_Index].x, BP[A_Index].y, BP[A_Index].w, BP[A_Index].w)
		Gdip_DeleteBrush( Brush3 )
		Gdip_DrawRectangle(BGMain.G, BPen,0, 0, 299, 199)

	}
	BGMain.UpdateWindow()
	return





;######################################################################################################################################################################################
;######################################################################################################################################################################################
;######################################################################################################################################################################################
class LayeredWindow	{
	__New( x := 0 , y := 0 , w := 100 , h := 100 , window := 1 , title := " " , smoothing := 4 , options := "" , autoShow := 1 , GdipStart := 0 , WinMover := "" , BackgroundColor := "" ){
		This.X := x , This.Y := y , This.W := w , This.H := h , This.Window := window , This.Title := title , This.Options := options , This.Smoothing := smoothing
		( GdipStart ) ? ( This.Token := Gdip_Startup() )
		This._CreateWindow()
		( autoShow ) ? ( This.ShowWindow() )
		This._SetUpdateLayeredWindow()
		( WinMover ) ? ( This._AddMoveTrigger( WinMover ) )
		( BackgroundColor ) ? ( This.PaintBackground( BackgroundColor , 1 ) )
	}_CreateWindow(){
		Gui , % This.Window ": New" , % " +E0x80000 +LastFound -Caption " This.Options 
		This.Hwnd := WinExist()
		This.hbm := CreateDIBSection( This.W , This.H )
		This.hdc := CreateCompatibleDC()
		This.obm := SelectObject( This.hdc , This.hbm )
		This.G := Gdip_GraphicsFromHDC( This.hdc )
		Gdip_SetSmoothingMode( This.G , This.Smoothing )
	}_SetUpdateLayeredWindow(){
		UpdateLayeredWindow( This.hwnd , This.hdc , This.X , This.Y , This.W , This.H )
	}UpdateWindow(){
		UpdateLayeredWindow( This.hwnd , This.hdc )
	}ShowWindow( update := 1 , Position := "" ){ 
		if( !Position )
			Gui , % This.Window ": Show" , % "w" This.W " h" This.H  , % ( This.Title ) ? ( This.Title ) : ( "" )
		else
			Gui , % This.Window ": Show" , % "x" Position.X " y" Position.Y "w" Position.W " h" Position.H  , % ( This.Title ) ? ( This.Title )  : ( "" )
		( update ) ? ( This.UpdateWindow() )
	}_AddMoveTrigger( positons ){ 
		local hwnd , bd
		Gui , % This.Window " : Add" , Text , % "x" positons.x " y" positons.y " w" positons.w " h" positons.h " hwndhwnd BackgroundTrans"
		This.MoveHwnd := hwnd
		bd := This._WindowMover.Bind( This )
		GuiControl , % This.Window ": +G" , % This.MoveHwnd , % bd
	}_WindowMover(){ 
		PostMessage, 0xA1 , 2
	}PaintBackground( BackgroundColor := "0xFF000000" , update := 0){ 
		local Brush
		This.BackgroundColor := BackgroundColor
		Brush := Gdip_BrushCreateSolid( BackgroundColor )
		Gdip_FillRectangle( This.G , Brush , 0 , 0 , This.W , This.H )
		Gdip_DeleteBrush( Brush )
		( update ) ? ( This.UpdateWindow() )
	}Draw( pBitmap , Positions := "" , update := 1 , disposeBitmap := 0  , PaintBackground := 0){ 
		(PaintBackground) ? ( This.PaintBackground( This.BackgroundColor ) )	
		Gdip_DrawImage( This.G , pBitmap , ( Positions.X1 ) ? ( Positions.X1 ) : ( Positions.X ) ? ( Positions.X ) : ( "" ) , ( Positions.Y1 ) ? ( Positions.Y1 ) : ( Positions.Y ) ? ( Positions.Y ) : ( "" ) , ( Positions.W1 ) ? ( Positions.W1 ) : ( Positions.W ) ? ( Positions.W ) : ( "" ) , ( Positions.H1 ) ? ( Positions.H1 ) : ( Positions.H ) ? ( Positions.H ) : ( "" ) , ( Positions.X2 ) ? ( Positions.X2 ) : ( Positions.SX ) ? ( Positions.SX ) : ( "" ) , ( Positions.Y2 ) ? ( Positions.Y2 ) : ( Positions.SY ) ? ( Positions.SY ) : ( "" ) , ( Positions.W2 ) ? ( Positions.W2 ) : ( Positions.SW ) ? ( Positions.SW ) : ( "" ) , ( Positions.H2 ) ? ( Positions.H2 ) : ( Positions.SH ) ? ( Positions.SH ) : ( "" ) )
		( update ) ? ( This.UpdateWindow() )
		( disposeBitmap ) ? ( Gdip_DisposeImage( pBitmap ) )
	}ClearWindow( update := "" ){ 
		Gdip_GraphicsClear( This.G )
		( update ) ? ( This.UpdateWindow() )
	}DeleteWindow( TurnOffGdip := 0 ){
		SelectObject( This.hdc , This.obm ) , DeleteObject( This.hbm ) , DeleteDC( This.hdc ) , Gdip_DeleteGraphics( This.G )
		( TurnOffGdip && This.Token ) ? ( Gdip_Shutdown( This.Token ) )
		Gui, % This.Window " : Destroy"
	}
}



BannerTag(txt := "Wash Your Hands" ){
	;Bitmap Created Using: HB Bitmap Maker
	pBitmap:=Gdip_CreateBitmap( 160 , 30 ),G := Gdip_GraphicsFromImage( pBitmap ),Gdip_SetSmoothingMode( G , 2 )
	Brush := Gdip_BrushCreateSolid( "0xFF888888" )
	Gdip_FillRoundedRectangle( G , Brush , 1 , 2 , 157 , 26 , 4 )
	Gdip_DeleteBrush( Brush )
	;~ Brush := Gdip_BrushCreateSolid( "0xFF333333" )
	Brush := Gdip_BrushCreateSolid( "0xFF171719" )
	Gdip_FillRoundedRectangle( G , Brush , 2 , 3 , 155 , 24 , 3 )
	Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( "0xFFaaaaaa" )
	Gdip_TextToGraphics( G , txt , "s16 Center vCenter Bold c" Brush " x-1 y0" , "Segoe ui" , 160 , 30 )
	Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( "0xFF770000" )
	Gdip_TextToGraphics( G , txt , "s16 Center vCenter Bold c" Brush " x0 y1" , "Segoe ui" , 160 , 30 )
	Gdip_DeleteBrush( Brush )
	Gdip_DeleteGraphics( G )
	return pBitmap
}

TogClButtSet1(value:=0){
	;Bitmap Created Using: HB Bitmap Maker
	pBitmap:=Gdip_CreateBitmap( 280 , 150 ) 
	G := Gdip_GraphicsFromImage( pBitmap )
	Gdip_SetSmoothingMode( G , 2 )
	;Hotkeys
	Brush := Gdip_CreateLineBrushFromRect( 29 , 36 , 221 , 28 , (Value=1)?("0xFFaa0000"):("0xFF880000")  , "0xFF000000" , 1 , 1 )
	Gdip_FillRoundedRectangle( G , Brush , 30 , 35 , 220 , 30 , 5 )
	Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( (Value=1)?("0x44000000"):("0x44222222") )
	Gdip_FillRoundedRectangle( G , Brush , 31 , 36 , 218 , 28 , 4 )
	Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( "0xFF777777" )
	Gdip_TextToGraphics( G , "Hotkeys" , "s16 Center vCenter Bold c" Brush " x30 y35" , "Segoe ui" , 218 , 28 )
	Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrushFromRect( 109 , 38 , 72 , 14 , (Value=1)?("0xFF000000"):("0xFF880000") , (Value=1)?("0xFF880000"):("0xFF000000") , 1 , 1 )
	Gdip_TextToGraphics( G , "Hotkeys" , "s16 Center vCenter Bold c" Brush " x31 y36" , "Segoe ui" , 218 , 28 )
	Gdip_DeleteBrush( Brush )
	;Click Speed
	Brush := Gdip_CreateLineBrushFromRect( 30 , 74 , 219 , 29 ,(Value=2)?("0xFFaa0000"):("0xFF880000") , "0xFF000000" , 1 , 1 )
	Gdip_FillRoundedRectangle( G , Brush , 30 , 75 , 220 , 30 , 4 )
	Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( (Value=2)?("0x44000000"):("0x44222222") )
	Gdip_FillRoundedRectangle( G , Brush , 31 , 76 , 218 , 28 , 4 )
	Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( "0xFF777777" )
	Gdip_TextToGraphics( G , "Click Speed" , "s16 Center vCenter Bold c" Brush " x30 y75" , "Segoe ui" , 218 , 28 )
	Gdip_DeleteBrush( Brush )
	Brush := Gdip_CreateLineBrushFromRect( 92 , 77 , 94 , 17 ,(Value=2)?("0xFF000000"):("0xFF880000") ,(Value=2)?("0xFF880000"):("0xFF000000") , 1 , 1 )
	Gdip_TextToGraphics( G , "Click Speed" , "s16 Center vCenter Bold c" Brush " x31 y76" , "Segoe ui" , 218 , 28 )
	Gdip_DeleteBrush( Brush )
	;More Options
	Brush := Gdip_CreateLineBrushFromRect( 31 , 115 , 216 , 27 ,(Value=3)?("0xFFaa0000"):("0xFF880000") , "0xFF000000" , 1 , 1 )
	Gdip_FillRoundedRectangle( G , Brush , 30 , 115 , 220 , 30 , 4 )
	Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( (Value=3)?("0x44000000"):("0x44222222") )
	Gdip_FillRoundedRectangle( G , Brush , 31 , 116 , 218 , 28 , 4 )
	Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( "0xFF777777" )
	Gdip_TextToGraphics( G , "More Options" , "s16 Center vCenter Bold c" Brush " x30 y115" , "Segoe ui" , 218 , 28 )
	Gdip_DeleteBrush( Brush )
	if(Value=3)
		Brush := Gdip_CreateLineBrushFromRect( 87 , 116 , 105 , 18 , "0xFF000000" , "0xFF880000" , 1 , 1 )
	else
		Brush := Gdip_CreateLineBrushFromRect( 87 , 116 , 105 , 18 , "0xFF880000" , "0xFF000000" , 1 , 1 )
	Gdip_TextToGraphics( G , "More Options" , "s16 Center vCenter Bold c" Brush " x31 y116" , "Segoe ui" , 218 , 28 )
	Gdip_DeleteBrush( Brush )
	Gdip_DeleteGraphics( G )
	return pBitmap 
}
^ Requires Windows 8+ ^
Hello, I need to be compatible with windows 7.
Hellbent wrote:
01 Apr 2020, 12:37
Moving the parent Pic control after the 2nd window is created seems to make a difference for me.

Code: Select all

Gui, background:New, +hwndhParent
Gui, child: New, +Parentbackground +HWNDhChild1 -0x80000000 +0x40000000 +E0x00010000
Gui, child: Add, Picture, x5 y5 w500 h500 BackgroundTrans, website.jpg
Gui, child: -Caption
gui, child: Show, x18 y17
gui, background: show, x0 y0 h500 w500, testBug
Gui, background:Add, Picture, x0 y0 h250 w250 BackgroundTrans, Moon.jpg
That works BUT if I submit the child gui and then show it again, the child gui will be behind the parent again.

Code: Select all

Gui, background:New, +hwndhParent -caption
Gui, child: New, +Parentbackground +HWNDhChild1 -0x80000000 +0x40000000 +E0x00010000
Gui, child: Add, Picture, x5 y5 w500 h500 BackgroundTrans, Moon.jpg
Gui, child: -Caption
gui, child: Show, x18 y17
gui, background: show, x0 y0 h500 w500, testBug
Gui, background:Add, Picture, x0 y0 h250 w250 BackgroundTrans, website.jpg

#SingleInstance, Force
#NoEnv
SetBatchLines, -1

f3::
gui, child:submit
return

f4::
gui, child:show
return
*esc::reload
User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: Child gui is always behind Parent gui

01 Apr 2020, 14:14

kyuuuri wrote:
01 Apr 2020, 13:54

That works BUT if I submit the child gui and then show it again, the child gui will be behind the parent again.
This does that for me. Give it a try.

Code: Select all

Gui, background:New, +hwndhParent -caption
Gui, child: New, +Parentbackground +HWNDhChild1 -0x80000000 +0x40000000 +E0x00010000
Gui, child: Add, Picture, x5 y5 w500 h500 BackgroundTrans, Moon.jpg
Gui, child: -Caption
gui, child: Show, x18 y17
gui, background: show, x0 y0 h500 w500, testBug
Gui, background:Add, Picture, x0 y0 h250 w250 BackgroundTrans hwndPic1, website.jpg

#SingleInstance, Force
#NoEnv
SetBatchLines, -1

f3::
GuiControl, background:+ReDraw, % Pic1
gui, child:submit
return

f4::
GuiControl, background:-ReDraw, % Pic1
gui, child:show,
return
*esc::reload
kyuuuri
Posts: 340
Joined: 09 Jan 2016, 19:20

Re: Child gui is always behind Parent gui

01 Apr 2020, 14:21

Hellbent wrote:
01 Apr 2020, 14:14
kyuuuri wrote:
01 Apr 2020, 13:54

That works BUT if I submit the child gui and then show it again, the child gui will be behind the parent again.
This does that for me. Give it a try.

Code: Select all

Gui, background:New, +hwndhParent -caption
Gui, child: New, +Parentbackground +HWNDhChild1 -0x80000000 +0x40000000 +E0x00010000
Gui, child: Add, Picture, x5 y5 w500 h500 BackgroundTrans, Moon.jpg
Gui, child: -Caption
gui, child: Show, x18 y17
gui, background: show, x0 y0 h500 w500, testBug
Gui, background:Add, Picture, x0 y0 h250 w250 BackgroundTrans hwndPic1, website.jpg

#SingleInstance, Force
#NoEnv
SetBatchLines, -1

f3::
GuiControl, background:+ReDraw, % Pic1
gui, child:submit
return

f4::
GuiControl, background:-ReDraw, % Pic1
gui, child:show,
return
*esc::reload
That's a good workaround, is there any way to set the redraw option for the entire gui? My parent gui will have more controls than a simple picture
User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: Child gui is always behind Parent gui

01 Apr 2020, 14:37

kyuuuri wrote:
01 Apr 2020, 14:21
That's a good workaround, is there any way to set the redraw option for the entire gui? My parent gui will have more controls than a simple picture
I was thinking winset, but I didn't bother to look it up.

Here replace the code in the f4 hotkey with this

Code: Select all

gui, child:show,
Gui, child:+LastFound
WinSet, Redraw

kyuuuri
Posts: 340
Joined: 09 Jan 2016, 19:20

Re: Child gui is always behind Parent gui

01 Apr 2020, 15:25

Hellbent wrote:
01 Apr 2020, 14:37
kyuuuri wrote:
01 Apr 2020, 14:21
That's a good workaround, is there any way to set the redraw option for the entire gui? My parent gui will have more controls than a simple picture
I was thinking winset, but I didn't bother to look it up.

Here replace the code in the f4 hotkey with this

Code: Select all

gui, child:show,
Gui, child:+LastFound
WinSet, Redraw

Found another problem, if I alt tab the parent will be on top of the child again. I believe this is a bug in how ahk handles guis.

@Edit: also if the child gui has transparent background, when I use redraw I can click through the entire gui, even through the parent.

@edit2: I don't understand how other apps do this. All I need is that 1 main gui and inside it more guis without caption or borders, so I can navigate between those by hiding and showing them.
The only alternatives I know are:
Parent: buggy as hell. Child behind parent, problems with transparency, etc.
Owner: buggy as hell as well. Child not tied to owner, coords non-relative to parent, moving parent doesn't move the child, can alt-tab to child guis even if they don't have the task bar icon, etc.
User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: Child gui is always behind Parent gui

01 Apr 2020, 16:03

Ok, I think I have it.

***Edit***
Fixed a issue with the button displaying in certain cases
Last edited by Hellbent on 01 Apr 2020, 16:31, edited 1 time in total.
User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: Child gui is always behind Parent gui

01 Apr 2020, 17:42

is there any way to set the redraw option for the entire gui? My parent gui will have more controls than a simple picture
I can't find one to do the whole gui, you can cycle through your controls

Code: Select all

#SingleInstance, Force
#NoEnv
SetBatchLines, -1
SetControlDelay,-1
Hwnds := []
Gui, background:New, +hwndhParent
Y:=20
Loop 10	{
	Gui, background:Add, Button,x20 y%y% w150 h10 hwndhwnd gTrigger, Other control
	Hwnds.Push(hwnd)
	GuiControl, background:-ReDraw, % hwnd
	y+=10
}
Gui, child: New, +Parentbackground +HWNDhChild1 -0x80000000 +0x40000000 +E0x00010000 
Gui, child: Add, Picture, x0 y0 w500 h500 , C:\Users\Hellbent\Desktop\AHK Tools\Color Picker Mini\Screen Shots\20200219064544.png
Gui, child: -Caption
gui, child: Show, x18 y17
gui, background: show, x0 y0 h500 w500, testBug
Gui, background:Add, Picture, x0 y0 h250 w250 hwndhwnd,C:\Users\Hellbent\Desktop\AHK Tools\Color Picker Mini\Screen Shots\20200217182528.png
Hwnds.Push(hwnd)

return

f3::
Gui, background:Show,NA
gui, child:submit

GuiControl, background:+ReDraw, % Hwnds[Hwnds.MaxIndex()]
sleep, 1
Loop,% Hwnds.Length()-1	
	GuiControl, background:+ReDraw, % Hwnds[A_Index]
return

f4::
for,k,v in hwnds
	GuiControl, background:-ReDraw, % v
gui, child:show,
return
*esc::ExitApp

Trigger:
	ToolTip, Button Pressed
	return
kyuuuri
Posts: 340
Joined: 09 Jan 2016, 19:20

Re: Child gui is always behind Parent gui  Topic is solved

01 Apr 2020, 20:35

Hellbent wrote:
01 Apr 2020, 17:42
is there any way to set the redraw option for the entire gui? My parent gui will have more controls than a simple picture
I can't find one to do the whole gui, you can cycle through your controls

Code: Select all

#SingleInstance, Force
#NoEnv
SetBatchLines, -1
SetControlDelay,-1
Hwnds := []
Gui, background:New, +hwndhParent
Y:=20
Loop 10	{
	Gui, background:Add, Button,x20 y%y% w150 h10 hwndhwnd gTrigger, Other control
	Hwnds.Push(hwnd)
	GuiControl, background:-ReDraw, % hwnd
	y+=10
}
Gui, child: New, +Parentbackground +HWNDhChild1 -0x80000000 +0x40000000 +E0x00010000 
Gui, child: Add, Picture, x0 y0 w500 h500 , C:\Users\Hellbent\Desktop\AHK Tools\Color Picker Mini\Screen Shots\20200219064544.png
Gui, child: -Caption
gui, child: Show, x18 y17
gui, background: show, x0 y0 h500 w500, testBug
Gui, background:Add, Picture, x0 y0 h250 w250 hwndhwnd,C:\Users\Hellbent\Desktop\AHK Tools\Color Picker Mini\Screen Shots\20200217182528.png
Hwnds.Push(hwnd)

return

f3::
Gui, background:Show,NA
gui, child:submit

GuiControl, background:+ReDraw, % Hwnds[Hwnds.MaxIndex()]
sleep, 1
Loop,% Hwnds.Length()-1	
	GuiControl, background:+ReDraw, % Hwnds[A_Index]
return

f4::
for,k,v in hwnds
	GuiControl, background:-ReDraw, % v
gui, child:show,
return
*esc::ExitApp

Trigger:
	ToolTip, Button Pressed
	return
I found the fix.

The problem was caused by an image on the parent gui.
My structure was:

Code: Select all

+ ParentGui with backgroundImage
	+ ChildGui with controls
To fix the problem I simply added another child gui between them:

Code: Select all

+ ParentGui
	+ ChildGui with backgroundImage
	+ ChildGui with controls
User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: Child gui is always behind Parent gui

02 Apr 2020, 02:11

kyuuuri wrote:
01 Apr 2020, 20:35
I found the fix.

The problem was caused by an image on the parent gui.
My structure was:

Code: Select all

+ ParentGui with backgroundImage
	+ ChildGui with controls
To fix the problem I simply added another child gui between them:

Code: Select all

+ ParentGui
	+ ChildGui with backgroundImage
	+ ChildGui with controls
That sounds a lot like the code I posted and removed, but there was still some issues with controls like buttons on the "background" gui.
It worked perfectly, except if a control had the cursor over it when the hotkey was pressed.

Code: Select all

Gui,1:+AlwaysOnTop
Gui, background: +hwndhParent -caption +Parent1  +Disabled 
Gui, background:Add, Picture, x0 y0 h250 w250 hwndPic1, website.jpg
Gui, background:Add, Button,x40 y60 w150 h40 hwndhwnd gTrigger, Other control
gui, background: show, x0 y0 h500 w500, testBug
Gui, child: +Parent1 +HWNDhChild1 -0x80000000 +0x40000000 +E0x00010000 -0x4000000 
Gui, child: Add, Picture, x5 y5 w500 h500 , Moon.jpg
Gui, child: -Caption
gui, child: Show, x18 y17
Gui,1:Show ,w500 h500
return

f3::
Gui,background:-Disabled
gui, child:submit
return

f4::
Gui,background:+Disabled 
gui, child:show,
return

Trigger:
	ToolTip, Button Pressed
	return

*esc::ExitApp
Spoiler
Would you mind posting a example of how you have your code?
kyuuuri
Posts: 340
Joined: 09 Jan 2016, 19:20

Re: Child gui is always behind Parent gui

02 Apr 2020, 11:23

Hellbent wrote:
02 Apr 2020, 02:11
kyuuuri wrote:
01 Apr 2020, 20:35
I found the fix.

The problem was caused by an image on the parent gui.
My structure was:

Code: Select all

+ ParentGui with backgroundImage
	+ ChildGui with controls
To fix the problem I simply added another child gui between them:

Code: Select all

+ ParentGui
	+ ChildGui with backgroundImage
	+ ChildGui with controls
That sounds a lot like the code I posted and removed, but there was still some issues with controls like buttons on the "background" gui.
It worked perfectly, except if a control had the cursor over it when the hotkey was pressed.

Code: Select all

Gui,1:+AlwaysOnTop
Gui, background: +hwndhParent -caption +Parent1  +Disabled 
Gui, background:Add, Picture, x0 y0 h250 w250 hwndPic1, website.jpg
Gui, background:Add, Button,x40 y60 w150 h40 hwndhwnd gTrigger, Other control
gui, background: show, x0 y0 h500 w500, testBug
Gui, child: +Parent1 +HWNDhChild1 -0x80000000 +0x40000000 +E0x00010000 -0x4000000 
Gui, child: Add, Picture, x5 y5 w500 h500 , Moon.jpg
Gui, child: -Caption
gui, child: Show, x18 y17
Gui,1:Show ,w500 h500
return

f3::
Gui,background:-Disabled
gui, child:submit
return

f4::
Gui,background:+Disabled 
gui, child:show,
return

Trigger:
	ToolTip, Button Pressed
	return

*esc::ExitApp
Spoiler
Would you mind posting a example of how you have your code?

Code: Select all

gui, main:New, +hwndhParent
Gui, background:New, +parentmain -caption
Gui, child: New, +parentmain -caption 
Gui, child: Add, Picture, x5 y5 w200 h200 BackgroundTrans, Moon.jpg
Gui, child: -Caption
gui, child: Show, x18 y17
Gui, background:Add, Picture, h250 w250 BackgroundTrans, website.jpg
gui, background: show, x100 y100 h500 w500, testBug
gui, main:show, w500 h500
#SingleInstance, Force
#NoEnv
SetBatchLines, -1

f3::
gui, child:hide
return

f4::
gui, child:show
return

f5::
gui, background:hide
return

f6::
gui, background:show
return
*esc::reload
You need to use a parent gui without any controls because if you don't then the controls will overlap between the child guis.
Then with the order of the child guis you have the order in the Z axis (front, back).
User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: Child gui is always behind Parent gui

04 Apr 2020, 03:19

@kyuuuri
Cool, I had played around with a bunch of combos but none had the desired effect. Thanks for sharing your solution.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: filipemb, kingina, mcd and 195 guests