Jump to content
Sign in to follow this  
martin

Set child window at the top

Recommended Posts

martin

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.

Share this post


Link to post
Share on other sites
Valuater

Click the "RED" then the "YELLOW"

... or vice versa!! ^_^

#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 by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites
martin

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.

Share this post


Link to post
Share on other sites
martin

Click the "RED" then the "YELLOW"

... or vice versa!! ;)

#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.

Share this post


Link to post
Share on other sites
Valuater

^_^ 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)


NEWHeader1.png

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×