#pragma once
|
|
class CWindowEnumer
|
{
|
CWindowEnumer();
|
~CWindowEnumer();
|
static std::vector<SOUI::CRect> rcList;
|
public:
|
//»ñÈ¡ËùÓÐÏî²ã´°¿Ú²¢»ñÈ¡¾ØÐÎ
|
static void EnumAllTopWindow()
|
{
|
//»ñÈ¡ÆÁÄ»ÉÏËùÓеĶ¥²ã´°¿Ú,ÿ·¢ÏÖÒ»¸ö´°¿Ú¾Íµ÷Óûص÷º¯ÊýÒ»´Î
|
HWND hWnd = GetDesktopWindow(); //µÃµ½×ÀÃæ´°¿Ú
|
hWnd = GetWindow(hWnd, GW_CHILD); //µÃµ½ÆÁÄ»ÉϵÚÒ»¸ö×Ó´°¿Ú
|
rcList.clear();
|
while (hWnd != NULL) //Ñ»·µÃµ½ËùÓеÄ×Ó´°¿Ú
|
{
|
if (IsWindowVisible(hWnd)) //ÅжÏÊÇ·ñ¶¥²ã´°¿Ú²¢Çҿɼû
|
{
|
SOUI::CRect WindowRc;
|
GetWindowRect(hWnd,&WindowRc);
|
if(!WindowRc.IsRectEmpty())
|
rcList.push_back(WindowRc);
|
}
|
hWnd = GetNextWindow(hWnd, GW_HWNDNEXT);
|
}
|
}
|
static SOUI::CRect GetPointInRect(POINT pt)
|
{/*
|
for (auto &rc:rcList)
|
{
|
if (rc.PtInRect(pt))
|
return rc;
|
}*/
|
for (std::vector<SOUI::CRect>::const_iterator ite= rcList.begin();ite!=rcList.end();ite++)
|
{
|
if (ite->PtInRect(pt))
|
return *ite;
|
}
|
|
return SOUI::CRect();
|
}
|
};
|