AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

GUI +alwaysontop Z-Order and Overlaying Multiple GUIs

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
CannedCheese



Joined: 21 May 2008
Posts: 120

PostPosted: Tue Dec 22, 2009 12:12 am    Post subject: GUI +alwaysontop Z-Order and Overlaying Multiple GUIs Reply with quote

I'm designing a "Main GUI" and think it would be simpler to overlay other GUIs as needed.

It seems easier to do this than to code for the Main gui to handle lots of different types of information.

I need the gui to be on top of everything but GUI 2 & GUI 3 (in other words, the 3 guis will attempt to function together on top of everything else, but with GUI 2 & GUI 3 on top of Main GUI 1).

I've created a code example. I run into problems:
1) whenever I click outside the main gui - If I set the main gui to +alwaysontop, it will cover up gui 2 & gui 3 whenever I click the main gui.
2) whenever I move the main gui, obvilously gui 2 & gui 3 don't naturally follow. Is there a way to fix this, or do I need to set a timer to always monitor the position of the main gui.

I hope what I'm looking for is clear. For a demo, run the following code and then click outside the main gui, and also drag it around.

Thanks!
Code:

gui -maximizebox -minimizebox -alwaysontop
gui, add, text,,GUI 1`nHow do I keep this gui on top without +alwaysontop`,`nsince +alwaysontop utilized on the main gui`nwill cover up GUI 2 & 3 any`ntime the main gui is clicked?`n`n`nFor example, please click outside the GUIs (e.g., your desktop) and GUI 1 disappears.`nHowever`, if we set GUI1 +alwaysontop, it covers GUI 2 and 3 whenver we click GUI1.`n`nAlso, how do I have GUI 2 and 3 move with GUI 1?  Is a loop required?
gui show, x10 y10 w500 h500
 
gui 2: -MaximizeBox -MinimizeBox -Caption +Border +alwaysontop +owner
gui 2: add, text,,GUI2
gui 2: show, x15 y200 w50 h100

gui 3: -MaximizeBox -MinimizeBox -Caption +Border +alwaysontop +owner
gui 3: add, text,,GUI 3
gui 3: show, x200 y350 w100 h50
Back to top
View user's profile Send private message
Zaelia



Joined: 31 Oct 2008
Posts: 604
Location: France

PostPosted: Tue Dec 22, 2009 2:52 am    Post subject: Reply with quote

Hi,

They are a lot of method but they are bug and other special "lag" that depend with version of windows and style of your OS.
I am noob (and french ^^) but I had searched a good method during a long time...

go to helpfile and check OnMessage list

for example:
OnMessage(0x232, "WM_EXITSIZEMOVE")

I think it's the beter method, because you can burn your CPU if you use other OnMessage (no redraw during move), but depend of what you need and what you want to show... check OnMessage list, you can find your happy^^

Other things you don't need to use +alwaysontop, if your GUI is always in pack you can use it as a "child" (with gui, 2:+owner1) , it's better because you can use your script like a normal apps ( always on top is crap when you parse an other windows to it) and only apps in your task bar ( so don't use toolwindows or other things )...

check gui owner also, it's like pyramid poperty...

advice: with this method, just for a beter skin, your GUI2 can have the same size than main gui, and main gui it just a "ghost" with a system bar (the system bar of main gui is essential during minimize windows coz they are some problem for minimize all child gui with vista (they duplicat it in taskbar dunno why, post message or not ) )

sorry again for my english I hope you understand... here a small example script than speack beter than me

Code:
OnMessage(0x232, "WM_EXITSIZEMOVE")

WM_EXITSIZEMOVE() {
IfWinExist, MAIN GUI
{
WinGetPos, X, Y, , , A ; you need to calcul position for other gui
Y2:=Y+50
X2:=X+50
Y3:=Y+150
X3:=X+100
gui, 2:show, x%X2% y%Y2%
; if option=showgui3 ; for example if it's pop up gui; else gui, 3:destroy ;becarfull it's a function some varaible must be in global mode I think
gui, 3:show, x%X3% y%Y3%
}
}

gui, 1:+alwaysontop
gui, 1:add, text,,GUI 1
gui, 1:show, x50 y50 w200 h200, MAIN GUI
 
gui, 2:+owner1 -Caption +Border
gui, 2:add, text,,GUI2
gui, 2:show, x100 y100 w50 h50

gui, 3:+owner1 -Caption +Border
gui, 3:add, text,,GUI3
gui, 3:show, x150 y200 w50 h50


other thing: You can use transparent background for gui2,3,X you will show background of main gui, but depend of option of gui because you can view desktop (so you can creat " real layers " )

problem: when you click gui 2 or 3, main gui is not "active", it's a very small problem but you can solve it with a settimer ( not a loop ), but depend of OS style and what you need ^^

if you have other question...
Back to top
View user's profile Send private message Send e-mail
CannedCheese



Joined: 21 May 2008
Posts: 120

PostPosted: Tue Dec 22, 2009 4:45 pm    Post subject: Reply with quote

Very, very, very helpful. I really appreciate it. This is exactly what I was looking for (I had surmised that I could use +owner somehow, but I didn't know how to use it).

I just got back from Paris, and I can assure you, your english is far better than my french. Thanks again!
Back to top
View user's profile Send private message
Micahs



Joined: 01 Dec 2006
Posts: 460

PostPosted: Wed Dec 23, 2009 10:29 am    Post subject: Reply with quote

You could try the 'setparent' api. Since the guis are in the same process, setparent works well. I modified your first example.

Code:
WS_POPUP = 0x80000000   ;needed for each child gui
WS_CHILD = 0x40000000

gui -MinimizeBox -MaximizeBox +LastFound
gui, add, text,,GUI 1`nHow do I keep this gui on top without +alwaysontop`,`nsince +alwaysontop utilized on the main gui`nwill cover up GUI 2 & 3 any`ntime the main gui is clicked?`n`n`nFor example, please click outside the GUIs (e.g., your desktop) and GUI 1 disappears.`nHowever`, if we set GUI1 +alwaysontop, it covers GUI 2 and 3 whenver we click GUI1.`n`nAlso, how do I have GUI 2 and 3 move with GUI 1?  Is a loop required?
parent_ID := WinExist()

subgui=2   ;you don't have to keep the gui var instead of the explicit declaration EG: "gui, 2: ..." but I just think this is easier (makes it much easier to copy\paste to add new items.)
Gui,%subgui%:margin,5,5
Gui, %subgui%: -Caption +ToolWindow +Border +%WS_CHILD% -%WS_POPUP%
gui, %subgui%: add, text,,GUI2
Gui, %subgui%: +LastFound
%subgui%_ID := WinExist()
DllCall("SetParent", "uint",  %subgui%_ID, "uint", parent_ID)
gui,  %subgui%: show, x15 y200 w50 h100  NA

subgui=3
Gui,%subgui%:margin,5,5
gui,%subgui%:-Caption +ToolWindow +Border +%WS_CHILD% -%WS_POPUP%
gui,%subgui%: add, text,,GUI 3
gui,%subgui%:+LastFound
%subgui%_ID := WinExist()
DllCall("SetParent", "uint", %subgui%_ID, "uint", parent_ID)
gui,%subgui%: show, x200 y350 w100 h50 NA

gui show, x10 y10 w500 h500

_________________
Back to top
View user's profile Send private message
CannedCheese



Joined: 21 May 2008
Posts: 120

PostPosted: Wed Dec 23, 2009 6:23 pm    Post subject: Reply with quote

Very, very cool. Looks like this alternative works as well. Thanks.
Back to top
View user's profile Send private message
Zaelia



Joined: 31 Oct 2008
Posts: 604
Location: France

PostPosted: Wed Dec 23, 2009 6:51 pm    Post subject: Reply with quote

Yeah! Micahs script is wonderfull !

However, mine is good for transparency, and we can creat gui layer ( good for 2D game, translucent filter, image overlapping, without dll, ... )
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group