1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
| bool Capture::getZOrder (std::vector<HWND> * res) {
std::map<HWND,std::pair<HWND,HWND> > wndNnext;
std::map<HWND,bool> vu;
if (!res) {
log->log(Logger::IMPORTANT, "Capture::getZOrder", "test0 echoue");
return false;
}
// Recupere les handles et leur GW_HWNDNEXT/GW_HWNDPREV
if (!EnumWindows (getWnd, (LPARAM)& wndNnext)) {
log->log(Logger::IMPORTANT, "Capture::getZOrder", "test1 echoue");
return false;
}
HWND h = NULL;
// Recupere le premier (zorder) handle
int f=0,e=0;
for (std::map<HWND,std::pair<HWND,HWND> >::iterator it = wndNnext.begin(); it != wndNnext.end(); it ++) {
vu[it->first] = false;
if (it->second.second == NULL) {
f++;
h = it->first;
}
if (it->second.first == NULL)
e++;
}
if (!h) {
log->log(Logger::IMPORTANT, "Capture::getZOrder", "test2 echoue");
return false;
}
if (f!=1) {
log->log(Logger::IMPORTANT, "Capture::getZOrder", "test3 echoue");
return false;
}
if (e!=1) {
log->log(Logger::IMPORTANT, "Capture::getZOrder", "test4 echoue");
return false;
}
do {
if (vu[h] == true) {
log->log(Logger::IMPORTANT, "Capture::getZOrder", "test5 echoue");
return false;
}
WINDOWPLACEMENT wndPl;
wndPl.length = sizeof(WINDOWPLACEMENT);
BOOL val = GetWindowPlacement (h, &wndPl);
if (val == 0) {
log->log(Logger::IMPORTANT, "Capture::getZOrder", "test6 echoue");
return false;
}
if (IsWindowVisible(h) && (wndPl.showCmd==SW_SHOWNORMAL||wndPl.showCmd==SW_SHOWMAXIMIZED))
res->push_back(h);
vu[h] = true;
h = wndNnext[h].first;
} while (h);
for (std::map<HWND,bool>::iterator it = vu.begin(); it!=vu.end(); it++)
if (it->second==false) {
log->log(Logger::IMPORTANT, "Capture::getZOrder", "test7 echoue");
return false;
}
return true;
}
BOOL CALLBACK Capture::getWnd (HWND hwnd, LPARAM lParam) {
std::map<HWND,std::pair<HWND,HWND> > * list = (std::map<HWND,std::pair<HWND,HWND> > *)lParam;
HWND hNext = GetNextWindow(hwnd, GW_HWNDNEXT);
HWND hPrev = GetNextWindow(hwnd, GW_HWNDPREV);
(*list)[hwnd].first = hNext;
(*list)[hwnd].second = hPrev;
return 1;
} |
Partager