-
Notifications
You must be signed in to change notification settings - Fork 0
/
pinlayerwnd.cpp
67 lines (53 loc) · 1.58 KB
/
pinlayerwnd.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
58
59
60
61
62
63
64
65
66
67
#include "stdafx.h"
#include "util.h"
#include "pinlayerwnd.h"
#include "resource.h"
LPCWSTR PinLayerWnd::className = L"EFPinLayerWnd";
bool PinLayerWnd::gotInitLButtonDown = false;
ATOM PinLayerWnd::registerClass()
{
WNDCLASS wc = {};
wc.lpfnWndProc = proc;
wc.hInstance = app.inst;
wc.hCursor = LoadCursor(app.inst, MAKEINTRESOURCE(IDC_PLACEPIN));
wc.lpszClassName = className;
return RegisterClass(&wc);
}
void PinLayerWnd::evLButtonDown(HWND wnd, UINT mk, int x, int y)
{
SetCapture(wnd);
if (!gotInitLButtonDown)
gotInitLButtonDown = true;
else {
ReleaseCapture();
POINT pt = { x, y };
if (ClientToScreen(wnd, &pt))
PostMessage(GetParent(wnd), App::WM_PINREQ, pt.x, pt.y);
DestroyWindow(wnd);
}
}
LRESULT CALLBACK PinLayerWnd::proc(HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
switch (msg) {
case WM_CREATE:
gotInitLButtonDown = false;
return false;
case WM_DESTROY:
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
if (wnd == app.layerWnd) app.layerWnd = 0;
return false;
case WM_LBUTTONDOWN:
evLButtonDown(wnd, wparam, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam));
return false;
case WM_LBUTTONUP:
case WM_RBUTTONUP:
case WM_MBUTTONUP:
case WM_KEYDOWN:
case WM_SYSKEYDOWN:
case WM_KILLFOCUS:
ReleaseCapture();
DestroyWindow(wnd);
return false;
}
return DefWindowProc(wnd, msg, wparam, lparam);
}