-
Notifications
You must be signed in to change notification settings - Fork 0
/
pinwnd.h
72 lines (63 loc) · 2.29 KB
/
pinwnd.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#pragma once
// Small popup window in the shape of pin.
// This is fully responsible for making the target window topmost.
//
class PinWnd {
public:
static ATOM registerClass();
static LRESULT CALLBACK proc(HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam);
static LPCWSTR className;
protected:
// Window data object.
//
class Data {
public:
// Attach to pin wnd and return object or 0 on error.
static Data* create(HWND pin, HWND callback) {
Data* p = new Data(callback);
SetLastError(0);
if (!SetWindowLong(pin, 0, LONG(p)) && GetLastError()) {
delete p;
p = 0;
}
return p;
}
// Get object or 0 on error.
static Data* get(HWND pin) {
return reinterpret_cast<Data*>(GetWindowLong(pin, 0));
}
// Detach from pin wnd and delete.
static void destroy(HWND pin) {
Data* p = get(pin);
if (!p)
return;
SetLastError(0);
if (!SetWindowLong(pin, 0, 0) && GetLastError())
return;
delete p;
}
HWND callbackWnd;
bool proxyMode;
HWND topMostWnd;
HWND proxyWnd;
HWND getPinOwner() const {
return proxyMode ? proxyWnd : topMostWnd;
}
private:
Data(HWND wnd) : callbackWnd(wnd), proxyMode(false), topMostWnd(0), proxyWnd(0) {}
};
static BOOL CALLBACK enumThreadWndProc(HWND wnd, LPARAM param);
static bool selectProxy(HWND wnd, const Data& pd);
static void fixTopStyle(HWND wnd, const Data& pd);
static void placeOnCaption(HWND wnd, const Data& pd);
static bool fixVisible(HWND wnd, const Data& pd);
static void fixPopupZOrder(HWND appWnd);
static LRESULT evCreate(HWND wnd, Data& pd);
static void evDestroy(HWND wnd, Data& pd);
static void evTimer(HWND wnd, Data& pd, UINT id);
static void evPaint(HWND wnd, Data& pd);
static void evLClick(HWND wnd, Data& pd);
static bool evPinAssignWnd(HWND wnd, Data& pd, HWND target, int pollRate);
static HWND evGetPinnedWnd(HWND wnd, Data& pd);
static void evPinResetTimer(HWND wnd, Data& pd, int pollRate);
};