I was unable to find anything that would directly give you the z-order of the window. However, you can try something like the following (warning, untested!)
int zindex = 0;
HWND window = GetTopWindow(GetParent(targetwindow));
while (window != targetwindow) {
zindex++;
window = GetNextWindow(window, GW_HWNDNEXT);
if (!window) {
zindex = -1;
break;
}
}
source
share