-
Jun 20th, 2020, 10:02 AM
#1
Thread Starter
Lively Member
How to find out if a form is 'on-top'?
Google returns countless articles/examples of how to set a form topmost or not_topmost using the SetWindowPos API. But, how do I determine if a Window has been set topmost? TIA. Bob.
-
Jun 20th, 2020, 10:23 AM
#2
Re: How to find out if a form is 'on-top'?
Code:
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongW" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Const GWL_EXSTYLE As Long = (-20)
Private Const WS_EX_TOPMOST As Long = &H8&
Private Function IsWindowTopMost(hWnd As Long) As Boolean
IsWindowTopMost = (GetWindowLong(hWnd, GWL_EXSTYLE) And WS_EX_TOPMOST) <> 0
End Function
-
Jun 20th, 2020, 10:32 AM
#3
Thread Starter
Lively Member
Re: How to find out if a form is 'on-top'?
-
Jun 20th, 2020, 11:27 AM
#4
Hyperactive Member
Re: How to find out if a form is 'on-top'?
I have a question about top-most. Is it possible to change a window's top-most state from top-most to not top-most and back again while it's running
-
Jun 20th, 2020, 02:08 PM
#5
Re: How to find out if a form is 'on-top'?
Originally Posted by Ordinary Guy
I have a question about top-most. Is it possible to change a window's top-most state from top-most to not top-most and back again while it's running
Didn't you say the examples showed you that in your first post, i.e. set the form to not_topmost.
Originally Posted by K4CY
Google returns countless articles/examples of how to set a form topmost or not_topmost using the SetWindowPos API. ....
Of course the form will still be on top if it is already on top. It just won't stay on top if you click on another window that overlaps the area it is in.
"Anyone can do any amount of work, provided it isn't the work he is supposed to be doing at that moment" Robert Benchley, 1930
-
Jun 20th, 2020, 02:16 PM
#6
Re: How to find out if a form is 'on-top'?
Originally Posted by passel
Didn't you say the examples showed you that in your first post, i.e. set the form to not_topmost.
Except Ordinary Guy isn't K4CY unless you know something we don't.
-
Jun 20th, 2020, 02:39 PM
#7
Hyperactive Member
Re: How to find out if a form is 'on-top'?
Originally Posted by passel
Didn't you say the examples showed you that in your first post, i.e. set the form to not_topmost.
Of course the form will still be on top if it is already on top. It just won't stay on top if you click on another window that overlaps the area it is in.
Not sure that is correct. If I have an app running top-most and I click on another app the top-most app will still be top-most otherwise it defeats the purpose of top-most
-
Jun 20th, 2020, 02:56 PM
#8
Re: How to find out if a form is 'on-top'?
OptionBase1, , didn't notice the interloper.
Ordinary Guy, you asked if the windows topmost state could be changed.
I was saying that it could.
Originally Posted by Ordinary Guy
Not sure that is correct. If I have an app running top-most and I click on another app the top-most app will still be top-most otherwise it defeats the purpose of top-most
I was saying if you set the app to no longer be top-most (which sounded like what you were asking), then it will not remain top-most. It won't automatically dive under other windows when you remove the top-most attribute, i.e. it will still be on top of other windows, until an overlapping window is selected.
"Anyone can do any amount of work, provided it isn't the work he is supposed to be doing at that moment" Robert Benchley, 1930
-
Jun 20th, 2020, 02:58 PM
#9
Hyperactive Member
Re: How to find out if a form is 'on-top'?
Here's my question rephrased. I have two apps. App2 is top-most. Now, at some point in time while both apps are running I want to make App1 top-most so it sits on top of App2. Later I want to make App1 not top-most thus allowing App2 to become top-most again so it sits on top of App1. I only have the exe of App2 but App1 is my app so I have total control over it. Is this possible?
-
Jun 20th, 2020, 03:43 PM
#10
Hyperactive Member
Re: How to find out if a form is 'on-top'?
OK, never mind, I got it to work like I want it
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|