I’m using the following code to get a handle of the topmost window:
HWND hwnd;
hwnd = GetForegroundWindow();
The problem with this is that it returns the top most system-wide.
Is there any way to get the topmost ONLY from my own application?
I want to get the top most window ONLY of my application. This means, that I need an API to get my own’s app top most window and NOT the systemwide top most window as GetForegroundWindow() does.
Thanks!
EDIT:
OK, let me be clear here. My problem is that I am able to get the HWND for a window that doesn’t belong to MY application.
What I want to get is the TOPMOST for ONLY my application.
If the HWND belongs to another application then I should not get the information.
Here is a callback you can use with EnumWindows():
As Adam points out, the LPARAM passed to EnumWindows() should be a pointer to an HWND. So you probably want to do something like this: