-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWindowFinder.h
47 lines (38 loc) · 1.21 KB
/
WindowFinder.h
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
#pragma once
#include "Array.h"
const int CLASS_BUF_SZ = 256;
typedef Array<HWND> ArrayHWND;
class WindowFinder
{
private:
// Static class, no instances allowed
WindowFinder() {};
~WindowFinder() {};
// Internal search instance data
struct SearchData
{
// Variables for temporary storing search criteria
bool find_all;
HWND wnd_parent;
const WCHAR* wnd_class;
ULONG_PTR wnd_pid;
// Found window(s)
union
{
HWND res_wnd;
ArrayHWND* res_wnds;
};
};
// Window enumeration callback function.
// lparam is a pointer to SearchData structure.
static BOOL CALLBACK EnumWindowProc(HWND hwnd, LPARAM lparam);
public:
// Find first window that is a direct child of 'parent', has class name 'wnd_class'
// and belongs to process 'pid'.
// If either of the arguments is NULL or 0 it is ignored.
static HWND FindWnd(HWND parent, bool direct_child, const WCHAR* wclass, ULONG_PTR pid);
// Find all windows that are direct children of 'parent', have class name 'wnd_class'
// and belong to process 'pid'.
// If either of the arguments is NULL or 0 it is ignored.
static ArrayHWND* FindWnds(HWND parent, bool direct_child, const WCHAR* wclass, ULONG_PTR pid);
};