How know if a window is above another
-
I have 2 windows, let's say a FileZilla window and a Notepad Window. And I have the FileZilla window is on the top of the Notepad one (like cards; on above the other). I want to know how could I get the information that the FileZilla window is above the notepad's one ? I tried
GetWindowLong
But no chance.LONG wndState1 = ::GetWindowLong(handler1, GWL_EXSTYLE);
LONG wndState2 = ::GetWindowLong(handler2, GWL_EXSTYLE);
both results is equal to 256. Is there a trick for that ?
"The Only Limit Is Only Your Imagination."
-
I have 2 windows, let's say a FileZilla window and a Notepad Window. And I have the FileZilla window is on the top of the Notepad one (like cards; on above the other). I want to know how could I get the information that the FileZilla window is above the notepad's one ? I tried
GetWindowLong
But no chance.LONG wndState1 = ::GetWindowLong(handler1, GWL_EXSTYLE);
LONG wndState2 = ::GetWindowLong(handler2, GWL_EXSTYLE);
both results is equal to 256. Is there a trick for that ?
"The Only Limit Is Only Your Imagination."
Try calling EnumDesktopWindows. I think it will give the window handles in their z-order to the callback function. I am not sure about this though. It would be fairly easy to contrive a test app to experiment with it. You might find EnumWindows will do it also. Between the two you should be able to determine what you want. Once you get the window handles in their z order you will have to determine which window is which, likely by their titles.
-
I have 2 windows, let's say a FileZilla window and a Notepad Window. And I have the FileZilla window is on the top of the Notepad one (like cards; on above the other). I want to know how could I get the information that the FileZilla window is above the notepad's one ? I tried
GetWindowLong
But no chance.LONG wndState1 = ::GetWindowLong(handler1, GWL_EXSTYLE);
LONG wndState2 = ::GetWindowLong(handler2, GWL_EXSTYLE);
both results is equal to 256. Is there a trick for that ?
"The Only Limit Is Only Your Imagination."
this discussion could also help: [c# - How to get the z-order in windows? - Stack Overflow](https://stackoverflow.com/questions/825595/how-to-get-the-z-order-in-windows)
-
this discussion could also help: [c# - How to get the z-order in windows? - Stack Overflow](https://stackoverflow.com/questions/825595/how-to-get-the-z-order-in-windows)
I need smthing that works with c++. :)
"The Only Limit Is Only Your Imagination."
-
I need smthing that works with c++. :)
"The Only Limit Is Only Your Imagination."
If you can do C++, then you can surely translate from C#. Especially since the functions you need to call are right in the code. :rolleyes:
The difficult we do right away... ...the impossible takes slightly longer.
-
I have 2 windows, let's say a FileZilla window and a Notepad Window. And I have the FileZilla window is on the top of the Notepad one (like cards; on above the other). I want to know how could I get the information that the FileZilla window is above the notepad's one ? I tried
GetWindowLong
But no chance.LONG wndState1 = ::GetWindowLong(handler1, GWL_EXSTYLE);
LONG wndState2 = ::GetWindowLong(handler2, GWL_EXSTYLE);
both results is equal to 256. Is there a trick for that ?
"The Only Limit Is Only Your Imagination."
Windows API has the function GetTopWindow GetTopWindow function (Windows)[^] From the TopWindow you want walk down thru the chain via GetNextWindow GetNextWindow function (Windows)[^] So in your case you want to ask the topWindow of the window that contains both FileZilla window and a Notepad Window. You can then walk along the chain using GetNextWindow and see which is above which just by asking the window title. Something like this will work
char buf[256];
HWND Wnd = GetTopWindow( /*handle of window containing both*/ );
GetWindowText(Wnd, &buf[0], sizeof(buf));
while (Wnd != 0 && !stricmp(&buf[0], "FileZilla") && !stricmp(&buf[0], "NotePad"))
{
Wnd = GetNextWindow(Wnd, GW_HWNDNEXT); // Next window
GetWindowText(Wnd, &buf[0], sizeof(buf)); // Get it's title
}
if (Wnd == 0) {
/* Error neither window found */
}
else {
/* Wnd is the topmost of 2 windows title and the string title is in buf */
}It is equivalent to EnumChildWindows function (Windows)[^] However for the simplicity you have it isn't worth setting up the enumeration function.
In vino veritas