AutoHotkey Community

It is currently May 27th, 2012, 12:46 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: December 22nd, 2009, 1:12 am 
Offline

Joined: May 22nd, 2008, 12:57 am
Posts: 120
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 22nd, 2009, 3:52 am 
Offline
User avatar

Joined: October 31st, 2008, 9:39 am
Posts: 641
Location: France
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...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 22nd, 2009, 5:45 pm 
Offline

Joined: May 22nd, 2008, 12:57 am
Posts: 120
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!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 23rd, 2009, 11:29 am 
Offline

Joined: December 1st, 2006, 9:27 am
Posts: 460
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

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 23rd, 2009, 7:23 pm 
Offline

Joined: May 22nd, 2008, 12:57 am
Posts: 120
Very, very cool. Looks like this alternative works as well. Thanks.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 23rd, 2009, 7:51 pm 
Offline
User avatar

Joined: October 31st, 2008, 9:39 am
Posts: 641
Location: France
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, ... )


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Leef_me, Ohnitiel, XstatyK, Yahoo [Bot] and 20 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group