aboutsummaryrefslogtreecommitdiff
path: root/c/common.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'c/common.cpp')
-rw-r--r--c/common.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/c/common.cpp b/c/common.cpp
index 2e16c59..fcf1da2 100644
--- a/c/common.cpp
+++ b/c/common.cpp
@@ -148,3 +148,17 @@ int EBMessageBox(const wchar_t* const wszText, const wchar_t* const wszCaption,
require(UnhookWindowsHookEx(hHook));
return r;
}
+
+int GetRelativeCursorPos(HWND hWnd, POINT* pt)
+{
+ RECT rc;
+ if (!GetClientRect(hWnd, &rc)) return 0;
+ SetLastError(ERROR_SUCCESS);
+ if (!MapWindowPoints(hWnd, NULL, (POINT*)&rc, 2)) return 0;
+
+ POINT ptMouse;
+ if (!GetCursorPos(&ptMouse)) return 0;
+ pt->x = ptMouse.x-rc.left;
+ pt->y = ptMouse.y-rc.top;
+ return 1;
+}