Sign in to follow this  
Followers 0
sshrum

Forcing a GUI to remain last in the z-order

7 posts in this topic

#1 ·  Posted (edited)

I wrote a multi monitor wallpaper / background app for Vista since they don't have Active Desktop support.

Dets here: http://www.shrum.net/code/vistas

Works nice for me but I'd like to lock the gui window to be last in the z-order (behind all my other active windows) and have that stick when the picture control is left-mouse clicked on (producing my context menus).

Possible?

Edit: Hmmm...last may be too deep if it puts my GUI behind the explorer shell...any thoughts?

Edited by sshrum

Sean Shrum :: http://www.shrum.net

All my published AU3-based apps and utilities

'Make it idiot-proof, and someone will make a better idiot'

 

Share this post


Link to post
Share on other sites



I wrote a multi monitor wallpaper / background app for Vista since they don't have Active Desktop support.

Dets here: http://www.shrum.net/code/vistas

Works nice for me but I'd like to lock the gui window to be last in the z-order (behind all my other active windows) and have that stick when the picture control is left-mouse clicked on (producing my context menus).

Possible?

Edit: Hmmm...last may be too deep if it puts my GUI behind the explorer shell...any thoughts?

Have a look at the SetWindowPos API call. It allows you to specifiy the position of a window relative to another window (like the desktop). You'll then need to put some code in your app that traps when your app is being pulled from it's desired position and call SetWindowPos to move it back where you want it.

Auto3Lib: A library of over 1200 functions for AutoIt

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Hey, what do I need to pass to the Z-order param to get it as last.

I've tried 0, 1, and -1

Edit: I just realized it wants a Hwnd...how do I find the Hwnd of the last window?

$aResult = DllCall("User32.dll", "int", "SetWindowPos", "hwnd", $aGuiHandles[$iMonitorNum], "hwnd", -1, "int", $aMonitorInfo[$iMonitorNum][1],  "int", $aMonitorInfo[$iMonitorNum][2], "int", $aMonitorInfo[$iMonitorNum][3], "int", $aMonitorInfo[$iMonitorNum][4], "int", 0)

Obviously the Z-order param is wrong but what do I need to do to get this call to send the Gui to the back?

TIA

Edited by sshrum

Sean Shrum :: http://www.shrum.net

All my published AU3-based apps and utilities

'Make it idiot-proof, and someone will make a better idiot'

 

Share this post


Link to post
Share on other sites

Hey, what do I need to pass to the Z-order param to get it as last.

I've tried 0, 1, and -1

Edit: I just realized it wants a Hwnd...how do I find the Hwnd of the last window?

$aResult = DllCall("User32.dll", "int", "SetWindowPos", "hwnd", $aGuiHandles[$iMonitorNum], "hwnd", -1, "int", $aMonitorInfo[$iMonitorNum][1],  "int", $aMonitorInfo[$iMonitorNum][2], "int", $aMonitorInfo[$iMonitorNum][3], "int", $aMonitorInfo[$iMonitorNum][4], "int", 0)

Obviously the Z-order param is wrong but what do I need to do to get this call to send the Gui to the back?

TIA

Here is the MSDN link for SetWindowPos. You need to pass the HWND_BOTTOM parameter for the hWndInsertAfter parameter and then pass the correct uFlags parameter to make it work. If you get stuck, this API call is implement in the Auto3Lib A3LWinAPI module, along with the required constants.

Auto3Lib: A library of over 1200 functions for AutoIt

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Sweet...that call does lock the GUI in the back even when I click on it and my context menus are still accessable

Freakin A! :whistle:

Thanks.

Edit1: Hmm...well, initially it seems to be locked down but then it seems to unlock (I'm checking my code for something I might be doing that is causing this).

Edit2: Well, if I use that call I get the GUI in the back. If I use @SW_DISABLE after I define the GUI, I get them locked into place however, I loose right-click context menuing. Any ideas on getting the context menus working again?

Edit3: (I seem to be answering my own ?s) I wrote in a section in my main loop that checks to see if a window with one of my titles is active. If it finds one (such as when a user left or right clicks on it), it pops it back to the back.

All is well with the world again!

Edited by sshrum

Sean Shrum :: http://www.shrum.net

All my published AU3-based apps and utilities

'Make it idiot-proof, and someone will make a better idiot'

 

Share this post


Link to post
Share on other sites

I'm trying to use the setwindowpos api to make a parent gui be infront of its child gui. I tried this but i dont know if i am using it correctly.

$Parent = GUICreate("Parent",200, 200)
GUISetState (@SW_SHOW)

$Child = GUICreate("Child", 200, 200, 100, 100, -1, -1, $Parent)
GUISetState (@SW_SHOW)

$iRet = DllCall("User32.dll", "int", "SetWindowPos", "Hwnd", $Child, "Hwnd", $Parent, _
          "int", 100, "int", 100, "int", 100, "int", 100, "uint", $SWP_NOSIZE + $SWP_NOMOVE)

[u]Scripts and UDF's[/u]WMMedia - UDF full of functions to Control Media Output.

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  
Followers 0