diff --git a/Library/DialogManage.cpp b/Library/DialogManage.cpp index 9d30c1a5..c9389dff 100644 --- a/Library/DialogManage.cpp +++ b/Library/DialogManage.cpp @@ -1219,8 +1219,7 @@ INT_PTR CDialogManage::CTabSkins::OnNotify(WPARAM wParam, LPARAM lParam) case NM_RCLICK: if (nm->idFrom == IDC_MANAGESKINS_SKINS_TREEVIEW) { - POINT pt; - GetCursorPos(&pt); + POINT pt = CSystem::GetCursorPosition(); TVHITTESTINFO ht; ht.pt = pt; diff --git a/Library/MeterWindow.cpp b/Library/MeterWindow.cpp index ade90076..98064816 100644 --- a/Library/MeterWindow.cpp +++ b/Library/MeterWindow.cpp @@ -2769,8 +2769,7 @@ LRESULT CMeterWindow::OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam) if (m_MouseOver) { - POINT pos; - GetCursorPos(&pos); + POINT pos = CSystem::GetCursorPosition(); if (!m_ClickThrough) { @@ -2933,8 +2932,7 @@ void CMeterWindow::ShowWindowIfAppropriate() { bool keyDown = IsCtrlKeyDown() || IsShiftKeyDown() || IsAltKeyDown(); - POINT pos; - GetCursorPos(&pos); + POINT pos = CSystem::GetCursorPosition(); POINT posScr = pos; MapWindowPoints(NULL, m_Window, &pos, 1); @@ -3210,8 +3208,7 @@ LRESULT CMeterWindow::OnMouseMove(UINT uMsg, WPARAM wParam, LPARAM lParam) */ LRESULT CMeterWindow::OnMouseLeave(UINT uMsg, WPARAM wParam, LPARAM lParam) { - POINT pos; - GetCursorPos(&pos); + POINT pos = CSystem::GetCursorPosition(); HWND hWnd = WindowFromPoint(pos); if (!hWnd || (hWnd != m_Window && GetParent(hWnd) != m_Window)) // ignore tooltips { @@ -3592,8 +3589,7 @@ LRESULT CMeterWindow::OnSysCommand(UINT uMsg, WPARAM wParam, LPARAM lParam) WriteOptions(OPTION_POSITION); } - POINT pos; - GetCursorPos(&pos); + POINT pos = CSystem::GetCursorPosition(); MapWindowPoints(NULL, m_Window, &pos, 1); // Handle buttons @@ -4455,8 +4451,7 @@ bool CMeterWindow::DoMoveAction(int x, int y, MOUSEACTION action) */ LRESULT CMeterWindow::OnMouseInput(UINT uMsg, WPARAM wParam, LPARAM lParam) { - POINT pos; - GetCursorPos(&pos); + POINT pos = CSystem::GetCursorPosition(); HWND hwnd = WindowFromPoint(pos); // Only process for unfocused skin window. diff --git a/Library/Rainmeter.cpp b/Library/Rainmeter.cpp index 2c1bab87..a7d9d1c1 100644 --- a/Library/Rainmeter.cpp +++ b/Library/Rainmeter.cpp @@ -488,8 +488,7 @@ void CRainmeter::Bang_SkinMenu(std::vector& args, CMeterWindow* me if (meterWindow) { - POINT pos; - GetCursorPos(&pos); + POINT pos = CSystem::GetCursorPosition(); ShowContextMenu(pos, meterWindow); } else @@ -504,8 +503,7 @@ void CRainmeter::Bang_SkinMenu(std::vector& args, CMeterWindow* me */ void CRainmeter::Bang_TrayMenu() { - POINT pos; - GetCursorPos(&pos); + POINT pos = CSystem::GetCursorPosition(); ShowContextMenu(pos, NULL); } diff --git a/Library/System.cpp b/Library/System.cpp index bb3e93ee..5e5db3fa 100644 --- a/Library/System.cpp +++ b/Library/System.cpp @@ -1052,6 +1052,17 @@ ULONGLONG CSystem::GetTickCount64() } } +/* +** Gets the cursor position in last message retrieved by GetMessage(). +** +*/ +POINT CSystem::GetCursorPosition() +{ + DWORD pos = GetMessagePos(); + POINT pt = { GET_X_LPARAM(pos), GET_Y_LPARAM(pos) }; + return pt; +} + /* ** Checks if file is writable. ** diff --git a/Library/System.h b/Library/System.h index 28949fd6..f2783288 100644 --- a/Library/System.h +++ b/Library/System.h @@ -69,6 +69,7 @@ public: static OSPLATFORM GetOSPlatform() { return c_Platform; } static ULONGLONG GetTickCount64(); + static POINT GetCursorPosition(); static bool IsPathSeparator(WCHAR ch) { return (ch == L'\\' || ch == L'/'); } static bool IsUNCPath(const std::wstring& path) { return (path.length() >= 2 && IsPathSeparator(path[0]) && IsPathSeparator(path[1])); } diff --git a/Library/TrayWindow.cpp b/Library/TrayWindow.cpp index dbaf0988..072cc416 100644 --- a/Library/TrayWindow.cpp +++ b/Library/TrayWindow.cpp @@ -604,9 +604,8 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA { if (tray->m_TrayContextMenuEnabled) { - POINT point; - GetCursorPos(&point); - Rainmeter->ShowContextMenu(point, NULL); + POINT pos = CSystem::GetCursorPosition(); + Rainmeter->ShowContextMenu(pos, NULL); } } else if (uMouseMsg == WM_LBUTTONUP || uMouseMsg == WM_LBUTTONDBLCLK)