﻿id	summary	reporter	owner	description	type	status	milestone	component	version	severity	resolution	keywords	cc
4071	$GUI_ONTOP sends labels to wrong end of z-order	MattyD	Jon	"Apologies if this should be a comment in #2287, I wasn't sure if that was still appropriate given the age of the ticket.

Anyway, the $GUI_ONTOP flag seems to send static controls to the wrong end of the z-order. Discussion is here:
https://www.autoitscript.com/forum/topic/213453-gui_ontop-label-controls/

Thanks,
Matt

{{{#!autoit
#include <GUIConstants.au3>
#include <WinAPI.au3>

_Example()

Func _Example()
	Local $hGUI = GUICreate(""Test"", 300, 200)
	GUISetState()

	GUICtrlCreateLabel(""Label 1"", 30, 30, 200, 100, $WS_CLIPSIBLINGS)
	GUICtrlSetBkColor(-1, 0xFF0000)

	GUICtrlCreateLabel(""Label 2"", 50, 45, 200, 100, $WS_CLIPSIBLINGS)
	GUICtrlSetBkColor(-1, 0x00FF00)

	GUICtrlCreateButton(""Button 1"", 70, 60, 200, 100, $WS_CLIPSIBLINGS)
	GUICtrlSetBkColor(-1, 0x0000FF)

	GUICtrlCreateEdit(""Edit 1"", 90, 75, 200, 100, $WS_CLIPSIBLINGS)
	GUICtrlSetBkColor(-1, 0xFFFF00)

	Local $aMsg, $hCtrl, $idCtrl
	Local $tPoint = DllStructCreate($tagPoint)
	While 1
		$aMsg = GUIGetMsg(1)
		Switch $aMsg[0]
			Case $GUI_EVENT_PRIMARYDOWN
				;Get control under the mouse.
				$tPoint.X = $aMsg[3]
				$tPoint.Y = $aMsg[4]
				_WinAPI_ClientToScreen($aMsg[1], $tPoint)
				$hCtrl = _WinAPI_WindowFromPoint($tPoint)
				$idCtrl = _WinAPI_GetDlgCtrlID($hCtrl)
				If Not $idCtrl Then ContinueLoop

				ConsoleWrite(StringFormat(""Clicked on CtrlID: %d (%s)"", $idCtrl, GUICtrlRead($idCtrl))& @CRLF)

				;Labels go to the back, Button & Edit controls come to the front
				GUICtrlSetState($idCtrl, $GUI_ONTOP)

	 			;All controls come to the front
;~ 	 			_WinAPI_BringWindowToTop($hCtrl)

;~	 			;All controls come to the front
;~ 	 			_WinAPI_SetWindowPos($hCtrl, $HWND_TOP, 0, 0, 0, 0, BitOR($SWP_NOMOVE, $SWP_NOSIZE))

			Case $GUI_EVENT_CLOSE
				ExitLoop
		EndSwitch
	WEnd

	GUIDelete($hGUI)
EndFunc
}}}"	Bug	assigned		AutoIt	3.3.18.0	None			
