Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Determining if a window is top most
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00173267
Message ID:
00173690
Views:
37
>>>>Is it possible to query a window to determine if it has been set as a top most window? I.e. if SetWindowPos() is used to set a window as top most ( HWND_TOPMOST ), is there an API function to query that window to determine if it is a top most window?
>>>>
>>>>Thanks,
>>>
>>>Hi Bill,
>>>
>>>You don't mean that you want the current foreground window (GetForegroundWindow), right? You can test if a window is a child window (IsChild), or loop through the windows like I do with the Is_Run function. That retrieves the handles of parent windows (top most) only.
>>
>>Hi George,
>>
>>It's not the specific foreground window I'm looking for but whether a window has been set as HWND_TOPMOST, i.e. above all non-topmost windows. I am looping thru the windows now ( this is in VB ... horrors :-) ) and I'm having to change my logic to make sure I hit all the windows and wanted to test to see if a window was set "topmost". As it turns out, because of the problem I was encountering ( yesterday ) and the solution I will implement ( today ), I won't need to test for this in my new solution. But now it's a matter of principle :-) and for future reference.
>>
>Hi Bill,
>
>AFAIK, the only way to do this is to loop through the top windows using GetWindow with GW_HWNDNEXT starting with the value retrieved by GetDesktopWindow. If it's any help, there's a function IsWindowVisible that takes the window handle as its only parameter it'll return a non-zero value if it is. The only word of caution I might add is that just because a window is topmost, that doesn't mean that there isn't a relationship to another window. For example, when you open help from within VFP the help window is topmost, but it's also owned by VFP. Thus, when VFP closes so does the help window. However, if you open it from the Explorer it isn't owned by another window (I guess technically it's owned by the desktop). You can open and close VFP and it won't close.

Hi George,

Thanks for the info. I hadn't thought of using GetDesktopWindow(), I was using GetWindow() with the GW_HWNDFIRST parameter to find the top-most window. This seems to work fine. Does it matter which method you use?

Fortunately I know which windows I'm looking for so the issue of whether it's owned by another is not a problem for me. I have noted the interesting effect that Help opened in VFP is shut down when VFP is. Hadn't thought of the ownership issue here. Also, I caught your other post and I understand.

At this point I can live w/o determining if a window is of top-most "status" or not. But what I'm getting from what you're saying is that there is no general way to determine if a window is of top-most "status" or not. It might be nice to do in some situations but if it's not possible ... oh well ... :-)

Bill
William A. Caton III
Software Engineer
MAXIMUS
Atlanta, Ga.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform