- int GetZOrder(HWND hTarget)
- {
- int index = 0;
- HWND hNext = ::GetTopWindow(NULL);
- do
- {
- hNext = ::GetNextWindow(hNext, GW_HWNDNEXT);
- if (hNext == hTarget)
- break;
- ++index;
- } while (hNext);
- return index;
- }
- // 예
- HWND hWnd1 = ::FindWindow(NULL, L"Daum - 모으다 잇다 흔들다 - Internet Explorer");
- HWND hWnd2 = ::FindWindow(NULL, L"Google - Internet Explorer");
- CString str;
- str.Format(_T("Daum %d; Google %d"), GetZOrder(hWnd1), GetZOrder(hWnd2));
- OutputDebugString(str.GetBuffer(0));