- 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,32 +2883,34 @@ 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);
}
if (_waccess(m_LogFile.c_str(), 0) == -1)
{
EnableMenuItem(subMenu, ID_CONTEXT_SHOWLOGFILE, MF_BYCOMMAND | MF_GRAYED);
EnableMenuItem(subMenu, ID_CONTEXT_DELETELOGFILE, MF_BYCOMMAND | MF_GRAYED);
EnableMenuItem(subMenu, ID_CONTEXT_STOPLOG, MF_BYCOMMAND | MF_GRAYED);
} }
else else
{ {
if (m_Logging) if (_waccess(m_LogFile.c_str(), 0) == -1)
{ {
EnableMenuItem(subMenu, ID_CONTEXT_STARTLOG, MF_BYCOMMAND | MF_GRAYED); EnableMenuItem(subMenu, ID_CONTEXT_SHOWLOGFILE, MF_BYCOMMAND | MF_GRAYED);
EnableMenuItem(subMenu, ID_CONTEXT_DELETELOGFILE, MF_BYCOMMAND | MF_GRAYED);
EnableMenuItem(subMenu, ID_CONTEXT_STOPLOG, MF_BYCOMMAND | MF_GRAYED);
} }
else else
{ {
EnableMenuItem(subMenu, ID_CONTEXT_STOPLOG, MF_BYCOMMAND | MF_GRAYED); if (m_Logging)
{
EnableMenuItem(subMenu, ID_CONTEXT_STARTLOG, MF_BYCOMMAND | MF_GRAYED);
}
else
{
EnableMenuItem(subMenu, ID_CONTEXT_STOPLOG, MF_BYCOMMAND | MF_GRAYED);
}
} }
}
if (c_Debug) if (c_Debug)
{ {
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);
@ -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)
{ {