kpassaur wrote:Did anyone ever find out how to make a Dialog stay on top once compiled? I used the example above and it works great until I compile it. Once compiled it goes to the back.
Hi
kpassaur,
JRL's solution from post:
Can a Dialog be made "Impossible to Minimize"? was:
JRL wrote:In a non modal dialog the line:
WindowAction>0,[Dialog Title]
Inserted into the GetDialogAction> loop will prevent the dialog from staying minimised.
For a modal dialog a second script or an executable could be spawned to perform the same function.
A secondary script like this:
Label>start
WindowAction>0,[Dialog Title]
Wait>0.01
Goto>start
Hope this helps,
Dick
So... applying JRL's suggestion to the example Marcus provided earlier in this post would give us this:
Code: Select all
Dialog>dlgMain
Caption=Main Dialog
Top=108
Width=451
Left=63
Height=250
Label=Main Dialog,64,16
EndDialog>dlgMain
Dialog>dlgStay
Caption=Stay On Top
Top=108
Width=267
Left=63
Height=143
Label=StayOnTop,32,16
Button=msButton1,24,72,75,25,2
EndDialog>dlgStay
Show>dlgMain
Show>dlgStay
Let>HWND_TOPMOST=-1
Let>HWND_NOTOPMOST=-2
Let>SWP_NOSIZE=1
Let>SWP_NOMOVE=2
Let>SWP_NOACTIVATE=16
Let>SWP_SHOWWINDOW=64
LibFunc>user32,FindWindowA,dhwnd,TForm,Stay On Top
Let>Flags={%SWP_NOACTIVATE% Or %SWP_SHOWWINDOW% Or %SWP_NOMOVE% Or %SWP_NOSIZE%}
LibFunc>User32,SetWindowPos,swpr,dhwnd,HWND_TOPMOST,0,0,0,0,Flags
Label>loop
//JRL: next line continuously restores "Stay On Top" dialog
WindowAction>0,Stay On Top
//Wait added so script won't hog CPU cycles and slow PC down
Wait>0.2
GetDialogAction>dlgMain,r
if>r=2,exit
Goto>loop
Label>exit
Don't forget a short Wait in the GetDialogAction> loop, see above.
I just tested this (using beta 9.0.031) in both compiled and non-compiled forms and the "Stay On Top" dialog cannot be minimized no matter what so this should work for you, however I did notice something curious...
- - in the non-compiled version, tapping Windows Key-D will alternately minimize and restore the "Main Dialog" which is what I'd expect.
- in the compiled version, tapping Windows Key-D minimizes the "Main Dialog" but tapping it again will not restore it (can be restored from the Taskbar however).
Marcus, shouldn't both uncompiled and compiled versions of this macro behave in the same way? Here's something else...
In the compiled version, when you run it, you'll notice an entry in the Taskbar right away... but nothing has been minimized yet. Hit Windows Key-D and the "Main Dialog" dissappears (minimizes I guess) but Taskbar still looks the same as it did when macro first ran.
Try it again, run compiled version only this time, click the minimize control on the "Main Dialog" window and see that it does minimize but not into the Taskbar, it creates a little mini-window just above the actual Taskbar. Can anyone explain what is actually happening here? Why doesn't it minimize to the Taskbar? Why does clicking the minimize control produce a different result than using
Keyboard shortcuts for Windows such as Windows Key-D?