Fixed focus on tray context menu

This commit is contained in:
spx 2012-10-25 18:26:46 +09:00
parent b2d245016a
commit 0388c63faf
2 changed files with 20 additions and 9 deletions

View File

@ -62,6 +62,7 @@ CTrayWindow::CTrayWindow() :
m_Values(), m_Values(),
m_Pos(), m_Pos(),
m_Notification(TRAY_NOTIFICATION_NONE), m_Notification(TRAY_NOTIFICATION_NONE),
m_TrayContextMenuEnabled(true),
m_IconEnabled(true) m_IconEnabled(true)
{ {
} }
@ -553,7 +554,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
} }
} }
} }
return 0; // Don't send WM_COMMANDS any further break; // Don't send WM_COMMANDS any further
case WM_TRAY_NOTIFYICON: case WM_TRAY_NOTIFYICON:
{ {
@ -579,18 +580,26 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
break; break;
} }
if (!IsCtrlKeyDown() && // Ctrl is pressed, so only run default action if (!bang.empty() &&
!bang.empty()) !IsCtrlKeyDown()) // Ctrl is pressed, so only run default action
{ {
Rainmeter->ExecuteCommand(bang.c_str(), NULL); Rainmeter->ExecuteCommand(bang.c_str(), NULL);
tray->m_TrayContextMenuEnabled = (uMouseMsg != WM_RBUTTONDOWN);
} }
else if (uMouseMsg == WM_RBUTTONDOWN) else if (uMouseMsg == WM_RBUTTONDOWN)
{
tray->m_TrayContextMenuEnabled = true;
}
else if (uMouseMsg == WM_RBUTTONUP)
{
if (tray->m_TrayContextMenuEnabled)
{ {
POINT point; POINT point;
GetCursorPos(&point); GetCursorPos(&point);
Rainmeter->ShowContextMenu(point, NULL); Rainmeter->ShowContextMenu(point, NULL);
} }
else if (uMouseMsg == WM_LBUTTONDOWN || uMouseMsg == WM_LBUTTONDBLCLK) }
else if (uMouseMsg == WM_LBUTTONUP || uMouseMsg == WM_LBUTTONDBLCLK)
{ {
CDialogManage::Open(); CDialogManage::Open();
} }
@ -705,8 +714,8 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
tray->TryAddTrayIcon(); tray->TryAddTrayIcon();
} }
} }
break;
}
return DefWindowProc(hWnd, uMsg, wParam, lParam); return DefWindowProc(hWnd, uMsg, wParam, lParam);
} }
return 0;
}

View File

@ -88,6 +88,8 @@ private:
TRAY_NOTIFICATION m_Notification; TRAY_NOTIFICATION m_Notification;
bool m_TrayContextMenuEnabled;
bool m_IconEnabled; bool m_IconEnabled;
}; };