- Fixed the issue that the context menu doesn't hide even if a focus is switched to the desktop or other windows.

- Fixed the small Logging menu issue.
This commit is contained in:
spx 2010-07-20 07:15:39 +00:00
parent eb536cde54
commit abc5df233d

View File

@ -2883,11 +2883,12 @@ void CRainmeter::ShowContextMenu(POINT pos, CMeterWindow* meterWindow)
{ {
if (!GetDummyLitestep()) if (!GetDummyLitestep())
{ {
// Disable Quit if ran as a Litestep plugin // Disable Quit/Logging if ran as a Litestep plugin
EnableMenuItem(subMenu, ID_CONTEXT_QUIT, MF_BYCOMMAND | MF_GRAYED); EnableMenuItem(subMenu, ID_CONTEXT_QUIT, MF_BYCOMMAND | MF_GRAYED);
EnableMenuItem(subMenu, ID_CONTEXT_SHOWLOGFILE, MF_BYCOMMAND | MF_GRAYED); EnableMenuItem(subMenu, 6, MF_BYPOSITION | MF_GRAYED);
} }
else
{
if (_waccess(m_LogFile.c_str(), 0) == -1) if (_waccess(m_LogFile.c_str(), 0) == -1)
{ {
EnableMenuItem(subMenu, ID_CONTEXT_SHOWLOGFILE, MF_BYCOMMAND | MF_GRAYED); EnableMenuItem(subMenu, ID_CONTEXT_SHOWLOGFILE, MF_BYCOMMAND | MF_GRAYED);
@ -2910,6 +2911,7 @@ void CRainmeter::ShowContextMenu(POINT pos, CMeterWindow* meterWindow)
{ {
CheckMenuItem(subMenu, ID_CONTEXT_DEBUGLOG, MF_BYCOMMAND | MF_CHECKED); CheckMenuItem(subMenu, ID_CONTEXT_DEBUGLOG, MF_BYCOMMAND | MF_CHECKED);
} }
}
HMENU configMenu = CreateConfigMenu(m_ConfigMenu); HMENU configMenu = CreateConfigMenu(m_ConfigMenu);
if (configMenu) if (configMenu)
@ -2960,18 +2962,26 @@ void CRainmeter::ShowContextMenu(POINT pos, CMeterWindow* meterWindow)
} }
} }
HWND hwnd = meterWindow ? meterWindow->GetWindow() : m_TrayWindow->GetWindow(); // Show context menu
SetForegroundWindow(hwnd); HWND hWnd = meterWindow ? meterWindow->GetWindow() : m_TrayWindow->GetWindow();
HWND hWndForeground = GetForegroundWindow();
if (hWndForeground != hWnd)
{
DWORD foregroundThreadID = GetWindowThreadProcessId(hWndForeground, NULL);
DWORD currentThreadID = GetCurrentThreadId();
AttachThreadInput(currentThreadID, foregroundThreadID, TRUE);
SetForegroundWindow(hWnd);
AttachThreadInput(currentThreadID, foregroundThreadID, FALSE);
}
TrackPopupMenu( TrackPopupMenu(
subMenu, subMenu,
TPM_RIGHTBUTTON | TPM_LEFTALIGN, TPM_RIGHTBUTTON | TPM_LEFTALIGN,
pos.x, pos.x,
pos.y, pos.y,
0, 0,
hwnd, hWnd,
NULL NULL
); );
PostMessage(hwnd, WM_NULL, 0L, 0L);
if (meterWindow) if (meterWindow)
{ {