Sign in to follow this  
Followers 0
SlowCoder74

WinSetOnTop - Taking Focus?

7 posts in this topic

I am writing another utility for my job that pulls data from a server and displays it on agent desktops.  It is critical that the information window remain on top of all other windows, including other windows that want to fight for "top position".

I placed my WinSetOnTop within my main loop.  It works nicely for me, 0 issues.  However, some of the agents have mentioned that since I deployed in beta, focus from their other application windows seems to get stolen.  Strange thing is it only seems to happen every once in a while.

Anyone have any ideas about this?

Share this post


Link to post
Share on other sites



SlowCoder74,

Try using:

GUISetState(@SW_SHOWNOACTIVATE, $hWnd)
when you display your GUI - that way the focus is never taken. :)

M23

1 person likes this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Let me just punch that into my test app and see what happens ...

... tickety clickety click ...

Ok, that doesn't make the window topmost. :mellow:  I can drag the window underneath other topmost windows.

Edited by SlowCoder74

Share this post


Link to post
Share on other sites

SlowCoder74,

That GUISetState parameter just prevents the focus from bring stolen by the GUI when it appears - which should solve your problem. Of course you still need to use the TOPMOST style or WinSetOnTop to get your GUI to the top of the z-order - sorry for any confusion. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Well, I never actually had to change anything.  The issue (if it existed in the first place) seems to have disappeared.  Thank you!

Share this post


Link to post
Share on other sites

I've experienced a situation with one of my scripts that seems very in line with the recommendations in this thread ... except that the pieces don't quite add up.

My script's GUI is created with $WS_POPUP and $WS_EX_TOPMOST ... which works in every instance when it runs amongst other programs.  It stays solidly on top ... EXCEPT when some embedded video is maximized from the browser.  The video takes over the screen and my GUI disappears behind it.  Even worse, the video overlays the taskbar, so I can't summon my GUI back.

What I've found, however, is that if I have another script running in background, that script can perform a WinSetOnTop($hMyGUI) and restore MyGUI to the top ... where is stays solidly, regardless of any click actions on the video ... even if the video is minimized and remaximized.

This leads me to believe that TopMost at creation is separate from the SetOnTop at runtime.

Is that the case?  And what is the prescribed GUISetState command for giving a GUI the best chance of staying on top following its initial display?  Should a script perform a SetOnTop() of itself?

Thanks in advance for clarifications.

 

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