- 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())
{
// 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_SHOWLOGFILE, MF_BYCOMMAND | MF_GRAYED);
EnableMenuItem(subMenu, 6, MF_BYPOSITION | MF_GRAYED);
}
else
{
if (_waccess(m_LogFile.c_str(), 0) == -1)
{
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);
}
}
HMENU configMenu = CreateConfigMenu(m_ConfigMenu);
if (configMenu)
@ -2960,18 +2962,26 @@ void CRainmeter::ShowContextMenu(POINT pos, CMeterWindow* meterWindow)
}
}
HWND hwnd = meterWindow ? meterWindow->GetWindow() : m_TrayWindow->GetWindow();
SetForegroundWindow(hwnd);
// Show context menu
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(
subMenu,
TPM_RIGHTBUTTON | TPM_LEFTALIGN,
pos.x,
pos.y,
0,
hwnd,
hWnd,
NULL
);
PostMessage(hwnd, WM_NULL, 0L, 0L);
if (meterWindow)
{