使用soui开发的mbc,只支持windows版本
w1146869587
2022-01-24 4905e2e7537d507f218e8e9595485e09d9f3a2b4
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
#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();
    }
};