-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlambdas.cpp
57 lines (47 loc) · 1.45 KB
/
lambdas.cpp
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
// {"category": "C++11", "notes": "Lambda expressions"}
#include <SDKDDKVer.h>
#include <stdio.h>
#include <tchar.h>
#include <vector>
#include <algorithm>
#include <Windows.h>
using namespace std;
//------------------------------------------------------------------------------
//
// Lambda expressions
//
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//
// Demo execution
//
//------------------------------------------------------------------------------
int _tmain(int argc, _TCHAR* argv[])
{
vector<HWND> childWindows;
EnumWindows([](_In_ HWND hwnd, _In_ LPARAM lParam) -> BOOL
{
EnumChildWindows(hwnd, [](_In_ HWND hwnd, _In_ LPARAM lParam) -> BOOL
{
reinterpret_cast<vector<HWND>*>(lParam)->push_back(hwnd);
return TRUE;
}, lParam);
return TRUE;
}, reinterpret_cast<LPARAM>(&childWindows));
const wstring tabWindowClass = L"TabWindowClass";
WCHAR text[MAX_PATH];
for_each(childWindows.begin(), childWindows.end(), [&](HWND hwnd)
{
if (RealGetWindowClassW(hwnd, text, ARRAYSIZE(text)) != 0)
{
if (text == tabWindowClass)
{
if (GetWindowTextW(hwnd, text, ARRAYSIZE(text)) != 0)
{
wprintf(L"%s\n", text);
}
}
}
});
return 0;
}