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:
if (nm->idFrom == IDC_MANAGESKINS_SKINS_TREEVIEW)
{
POINT pt;
GetCursorPos(&pt);
POINT pt = CSystem::GetCursorPosition();
TVHITTESTINFO ht;
ht.pt = pt;

View File

@ -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.

View File

@ -488,8 +488,7 @@ void CRainmeter::Bang_SkinMenu(std::vector<std::wstring>& 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<std::wstring>& args, CMeterWindow* me
*/
void CRainmeter::Bang_TrayMenu()
{
POINT pos;
GetCursorPos(&pos);
POINT pos = CSystem::GetCursorPosition();
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.
**

View File

@ -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])); }

View File

@ -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)