martin Posted May 5, 2009 Posted May 5, 2009 I cannot work out how to create a child window and set it the top of the Z-order. In the example which follows the first child created is at the top. The last created window is at the bottom. Can anyone tell me how I create a child window, (or a label because I can't do it with a label either) and force it to the top? #include <Constants.au3> #include <WindowsConstants.au3> #AutoIt3Wrapper_Add_Constants=n #include <winapi.au3> $Parent = GUICreate("main", 500, 500) GUISetState() $ch1 = GUICreate("child1", 200, 200, 0, 0, $WS_CHILD, -1, $Parent) GUISetBkColor(0xff0000, $ch1) GUISetState() $ch2 = GUICreate("child2", 300, 300, 100, 100, $WS_CHILD, -1, $Parent) GUISetBkColor(0x00FF00, $ch2) GUISetState() $gch1 = GUICreate("grandchild1", 200, 200, 60, 60, $WS_CHILD, -1, $ch2) GUISetBkColor(0xffffff) GUISetState() $ch3 = GUICreate("child 3", 200, 200, 300, 300, $WS_CHILD, -1, $Parent);$WS_EX_TOPMOST has no effect GUISetBkColor(0xFFFF00, $ch3) GUISetState() $iFlags = BitOR($SWP_SHOWWINDOW, 0);, $SWP_NOSIZE, $SWP_NOMOVE) _WinAPI_SetWindowPos($ch3, $HWND_TOPMOST, 0, 0, 0, 0, $iFlags);$HWND_TOP no different---I assume I'm doing something wrong here ;winsetontop($ch3,"",1);no effect but I assume it just uses SetWindowPos While GUIGetMsg() <> -3 WEnd EDIT: Or anything which lets me change the z order of any of the child windows? Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Valuater Posted May 5, 2009 Posted May 5, 2009 (edited) Click the "RED" then the "YELLOW" ... or vice versa!! expandcollapse popup#include <Constants.au3> #include <WindowsConstants.au3> #AutoIt3Wrapper_Add_Constants=n #include <winapi.au3> $Parent = GUICreate("main", 500, 500) GUISetState() $ch1 = GUICreate("child1", 200, 200, 0, 0, $WS_CHILD, -1, $Parent) GUISetBkColor(0xff0000, $ch1) GUISetState() $ch2 = GUICreate("child2", 300, 300, 100, 100, $WS_CHILD, -1, $Parent) GUISetBkColor(0x00FF00, $ch2) GUISetState() $gch1 = GUICreate("grandchild1", 200, 200, 60, 60, $WS_CHILD, -1, $ch2) GUISetBkColor(0xffffff) GUISetState() $ch3 = GUICreate("child 3", 200, 200, 300, 300, $WS_CHILD, -1, $Parent);$WS_EX_TOPMOST has no effect GUISetBkColor(0xFFFF00, $ch3) GUISetState() $iFlags = BitOR($SWP_SHOWWINDOW, 0);, $SWP_NOSIZE, $SWP_NOMOVE) _WinAPI_SetWindowPos($ch3, $HWND_TOPMOST, 0, 0, 0, 0, $iFlags);$HWND_TOP no different---I assume I'm doing something wrong here ;winsetontop($ch3,"",1);no effect but I assume it just uses SetWindowPos While 1 $Msg = GUIGetMsg(1) Select Case $Msg[0] = -3 Exit Case $Msg[1] = $ch3 WinMove($ch3, "", 160, 160) ; works Set_Focus($ch3) Case $Msg[1] = $ch1 WinMove($ch1, "", 160, 160) ; works Set_Focus($ch1) EndSelect WEnd Func Set_Focus(ByRef $GUI) $style = GUIGetStyle($GUI) GUISetStyle($DS_SETFOREGROUND, -1, $GUI) GUISetStyle($style[0], -1, $GUI) WinActivate($Parent) Return 1 EndFunc ;==>Set_Focus 8) Edited May 5, 2009 by Valuater
martin Posted May 5, 2009 Author Posted May 5, 2009 I cannot work out how to create a child window and set it the top of the Z-order. In the example which follows the first child created is at the top. The last created window is at the bottom. Can anyone tell me how I create a child window, (or a label because I can't do it with a label either) and force it to the top? #include <Constants.au3> #include <WindowsConstants.au3> #AutoIt3Wrapper_Add_Constants=n #include <winapi.au3> $Parent = GUICreate("main", 500, 500) GUISetState() $ch1 = GUICreate("child1", 200, 200, 0, 0, $WS_CHILD, -1, $Parent) GUISetBkColor(0xff0000, $ch1) GUISetState() $ch2 = GUICreate("child2", 300, 300, 100, 100, $WS_CHILD, -1, $Parent) GUISetBkColor(0x00FF00, $ch2) GUISetState() $gch1 = GUICreate("grandchild1", 200, 200, 60, 60, $WS_CHILD, -1, $ch2) GUISetBkColor(0xffffff) GUISetState() $ch3 = GUICreate("child 3", 200, 200, 300, 300, $WS_CHILD, -1, $Parent);$WS_EX_TOPMOST has no effect GUISetBkColor(0xFFFF00, $ch3) GUISetState() $iFlags = BitOR($SWP_SHOWWINDOW, 0);, $SWP_NOSIZE, $SWP_NOMOVE) _WinAPI_SetWindowPos($ch3, $HWND_TOPMOST, 0, 0, 0, 0, $iFlags);$HWND_TOP no different---I assume I'm doing something wrong here ;winsetontop($ch3,"",1);no effect but I assume it just uses SetWindowPos While GUIGetMsg() <> -3 WEnd EDIT: Or anything which lets me change the z order of any of the child windows? It does work with $HWND_TOP although I thought I'd tried that many times. Bad day Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
martin Posted May 5, 2009 Author Posted May 5, 2009 Click the "RED" then the "YELLOW" ... or vice versa!! expandcollapse popup#include <Constants.au3> #include <WindowsConstants.au3> #AutoIt3Wrapper_Add_Constants=n #include <winapi.au3> $Parent = GUICreate("main", 500, 500) GUISetState() $ch1 = GUICreate("child1", 200, 200, 0, 0, $WS_CHILD, -1, $Parent) GUISetBkColor(0xff0000, $ch1) GUISetState() $ch2 = GUICreate("child2", 300, 300, 100, 100, $WS_CHILD, -1, $Parent) GUISetBkColor(0x00FF00, $ch2) GUISetState() $gch1 = GUICreate("grandchild1", 200, 200, 60, 60, $WS_CHILD, -1, $ch2) GUISetBkColor(0xffffff) GUISetState() $ch3 = GUICreate("child 3", 200, 200, 300, 300, $WS_CHILD, -1, $Parent);$WS_EX_TOPMOST has no effect GUISetBkColor(0xFFFF00, $ch3) GUISetState() $iFlags = BitOR($SWP_SHOWWINDOW, 0);, $SWP_NOSIZE, $SWP_NOMOVE) _WinAPI_SetWindowPos($ch3, $HWND_TOPMOST, 0, 0, 0, 0, $iFlags);$HWND_TOP no different---I assume I'm doing something wrong here ;winsetontop($ch3,"",1);no effect but I assume it just uses SetWindowPos While 1 $Msg = GUIGetMsg(1) Select Case $Msg[0] = -3 Exit Case $Msg[1] = $ch3 WinMove($ch3, "", 160, 160) ; works Set_Focus($ch3) Case $Msg[1] = $ch1 WinMove($ch1, "", 160, 160) ; works Set_Focus($ch1) EndSelect WEnd Func Set_Focus(ByRef $GUI) $style = GUIGetStyle($GUI) GUISetStyle($DS_SETFOREGROUND, -1, $GUI) GUISetStyle($style[0], -1, $GUI) WinActivate($Parent) Return 1 EndFunc ;==>Set_Focus 8) Thanks Valuater, that's a clever way to do it! Obvious when you see it. I'll play with that. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Valuater Posted May 5, 2009 Posted May 5, 2009 Thanks Valuater, that's a clever way to do it! Obvious when you see it. I'll play with that.Welcome... I get lucky once in a while... 8)
TommyDDR Posted August 6, 2021 Posted August 6, 2021 I know it's an old topic, but i can't find a better solution than this post. But i found easier way to do it (258ms vs 1ms to process it) : You just need to call SetWindowsPos : expandcollapse popup#include <AutoItConstants.au3> #include <Misc.au3> #include <WinAPIMisc.au3> #include <WinAPISysInternals.au3> #include <WindowsConstants.au3> Opt("MustDeclareVars", 1) Global $Parent = GUICreate("main", 500, 500) GUISetState() Global $ch1 = GUICreate("child1", 200, 200, 0, 0, $WS_CHILD, -1, $Parent) GUISetBkColor(0xff0000, $ch1) GUISetState() Global $ch2 = GUICreate("child2", 300, 300, 100, 100, $WS_CHILD, -1, $Parent) GUISetBkColor(0x00FF00, $ch2) GUISetState() Global $gch1 = GUICreate("grandchild1", 200, 200, 60, 60, $WS_CHILD, -1, $ch2) GUISetBkColor(0xffffff) GUISetState() Global $ch3 = GUICreate("child 3", 200, 200, 300, 300, $WS_CHILD, -1, $Parent) GUISetBkColor(0xFFFF00, $ch3) GUISetState() Global $moveInfos[3] While 1 Local $Msg = GUIGetMsg(1) Select Case $Msg[0] = -3 Exit Case Else Local $hwnd = $Msg[1] If(IsHWnd($hwnd) And $hwnd <> $Parent) Then initMove($hwnd) EndIf EndSelect WEnd Func initMove($hwnd) $moveInfos[0] = $hwnd Local $tPoint = _WinAPI_GetMousePos(True, $hwnd) $moveInfos[1] = DllStructGetData($tPoint, "X") $moveInfos[2] = DllStructGetData($tPoint, "Y") _WinAPI_SetWindowPos($hwnd, $HWND_TOP, 0, 0, 0, 0, BitOR($SWP_NOMOVE, $SWP_NOSIZE)) AdlibRegister(move, 50) EndFunc Func move() If(_IsPressed("01")) Then Local $tPoint = _WinAPI_GetMousePos(True, _WinAPI_GetParent($moveInfos[0])) Local $mgp = [DllStructGetData($tPoint, "X"), DllStructGetData($tPoint, "Y")] Local $newPos = [$mgp[0] - $moveInfos[1], _ $mgp[1] - $moveInfos[2]] WinMove($moveInfos[0], "", $newPos[0], $newPos[1]) Else For $i = 0 To UBound($moveInfos, 1) - 1 $moveInfos[$i] = -1 Next AdlibUnRegister(move) EndIf EndFunc _GUIRegisterMsg (Register more than 1 time the same Msg), _Resize_Window (GUICtrlSetResizing for children windows), _GUICtrlSetOnHover (Link a function when mouse go on, left, clic down, clic up, on a control), _InputHeure (Create an input for hour contain), _GUICtrlCalendar (Make a complete calendar), _GUICtrlCreateGraphic3D (Create a 3D graph), _ArrayEx.au3 (Array management), _GUIXViewEx.au3 (List/Tree View management).
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now