Changed GetCursorPos() to GetMessagePos()

See: http://blogs.msdn.com/b/oldnewthing/archive/2009/06/18/9771135.aspx
This commit is contained in:
Birunthan Mohanathas 2012-11-24 13:22:33 +02:00
parent 950f86add1
commit 6a507dc761
6 changed files with 22 additions and 19 deletions

View File

@ -1219,8 +1219,7 @@ INT_PTR CDialogManage::CTabSkins::OnNotify(WPARAM wParam, LPARAM lParam)
case NM_RCLICK: case NM_RCLICK:
if (nm->idFrom == IDC_MANAGESKINS_SKINS_TREEVIEW) if (nm->idFrom == IDC_MANAGESKINS_SKINS_TREEVIEW)
{ {
POINT pt; POINT pt = CSystem::GetCursorPosition();
GetCursorPos(&pt);
TVHITTESTINFO ht; TVHITTESTINFO ht;
ht.pt = pt; ht.pt = pt;

View File

@ -2769,8 +2769,7 @@ LRESULT CMeterWindow::OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam)
if (m_MouseOver) if (m_MouseOver)
{ {
POINT pos; POINT pos = CSystem::GetCursorPosition();
GetCursorPos(&pos);
if (!m_ClickThrough) if (!m_ClickThrough)
{ {
@ -2933,8 +2932,7 @@ void CMeterWindow::ShowWindowIfAppropriate()
{ {
bool keyDown = IsCtrlKeyDown() || IsShiftKeyDown() || IsAltKeyDown(); bool keyDown = IsCtrlKeyDown() || IsShiftKeyDown() || IsAltKeyDown();
POINT pos; POINT pos = CSystem::GetCursorPosition();
GetCursorPos(&pos);
POINT posScr = pos; POINT posScr = pos;
MapWindowPoints(NULL, m_Window, &pos, 1); 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) LRESULT CMeterWindow::OnMouseLeave(UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
POINT pos; POINT pos = CSystem::GetCursorPosition();
GetCursorPos(&pos);
HWND hWnd = WindowFromPoint(pos); HWND hWnd = WindowFromPoint(pos);
if (!hWnd || (hWnd != m_Window && GetParent(hWnd) != m_Window)) // ignore tooltips 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); WriteOptions(OPTION_POSITION);
} }
POINT pos; POINT pos = CSystem::GetCursorPosition();
GetCursorPos(&pos);
MapWindowPoints(NULL, m_Window, &pos, 1); MapWindowPoints(NULL, m_Window, &pos, 1);
// Handle buttons // Handle buttons
@ -4455,8 +4451,7 @@ bool CMeterWindow::DoMoveAction(int x, int y, MOUSEACTION action)
*/ */
LRESULT CMeterWindow::OnMouseInput(UINT uMsg, WPARAM wParam, LPARAM lParam) LRESULT CMeterWindow::OnMouseInput(UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
POINT pos; POINT pos = CSystem::GetCursorPosition();
GetCursorPos(&pos);
HWND hwnd = WindowFromPoint(pos); HWND hwnd = WindowFromPoint(pos);
// Only process for unfocused skin window. // Only process for unfocused skin window.

View File

@ -488,8 +488,7 @@ void CRainmeter::Bang_SkinMenu(std::vector<std::wstring>& args, CMeterWindow* me
if (meterWindow) if (meterWindow)
{ {
POINT pos; POINT pos = CSystem::GetCursorPosition();
GetCursorPos(&pos);
ShowContextMenu(pos, meterWindow); ShowContextMenu(pos, meterWindow);
} }
else else
@ -504,8 +503,7 @@ void CRainmeter::Bang_SkinMenu(std::vector<std::wstring>& args, CMeterWindow* me
*/ */
void CRainmeter::Bang_TrayMenu() void CRainmeter::Bang_TrayMenu()
{ {
POINT pos; POINT pos = CSystem::GetCursorPosition();
GetCursorPos(&pos);
ShowContextMenu(pos, NULL); ShowContextMenu(pos, NULL);
} }

View File

@ -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. ** Checks if file is writable.
** **

View File

@ -69,6 +69,7 @@ public:
static OSPLATFORM GetOSPlatform() { return c_Platform; } static OSPLATFORM GetOSPlatform() { return c_Platform; }
static ULONGLONG GetTickCount64(); static ULONGLONG GetTickCount64();
static POINT GetCursorPosition();
static bool IsPathSeparator(WCHAR ch) { return (ch == L'\\' || ch == L'/'); } 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])); } static bool IsUNCPath(const std::wstring& path) { return (path.length() >= 2 && IsPathSeparator(path[0]) && IsPathSeparator(path[1])); }

View File

@ -604,9 +604,8 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
{ {
if (tray->m_TrayContextMenuEnabled) if (tray->m_TrayContextMenuEnabled)
{ {
POINT point; POINT pos = CSystem::GetCursorPosition();
GetCursorPos(&point); Rainmeter->ShowContextMenu(pos, NULL);
Rainmeter->ShowContextMenu(point, NULL);
} }
} }
else if (uMouseMsg == WM_LBUTTONUP || uMouseMsg == WM_LBUTTONDBLCLK) else if (uMouseMsg == WM_LBUTTONUP || uMouseMsg == WM_LBUTTONDBLCLK)