mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Additional tweaks to a4c7e83
This commit is contained in:
parent
a4c7e83391
commit
7c76cf8b2d
@ -65,19 +65,15 @@ void ContextMenu::ShowMenu(POINT pos, MeterWindow* meterWindow)
|
||||
MENU_ITEM(IDM_QUIT, ID_STR_EXIT)
|
||||
};
|
||||
|
||||
if (m_MenuActive || (meterWindow && meterWindow->IsClosing()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Rainmeter& rainmeter = GetRainmeter();
|
||||
|
||||
m_MenuActive = true;
|
||||
if (m_MenuActive || (meterWindow && meterWindow->IsClosing())) return;
|
||||
|
||||
// Show context menu, if no actions were executed
|
||||
HMENU menu = MenuTemplate::CreateMenu(s_Menu, _countof(s_Menu), GetString);
|
||||
if (menu)
|
||||
{
|
||||
if (!menu) return;
|
||||
|
||||
m_MenuActive = true;
|
||||
Rainmeter& rainmeter = GetRainmeter();
|
||||
|
||||
SetMenuDefaultItem(menu, IDM_MANAGE, MF_BYCOMMAND);
|
||||
|
||||
if (_waccess(GetLogger().GetLogFilePath().c_str(), 0) == -1)
|
||||
@ -172,8 +168,8 @@ void ContextMenu::ShowMenu(POINT pos, MeterWindow* meterWindow)
|
||||
HWND hWndForeground = GetForegroundWindow();
|
||||
if (hWndForeground != hWnd)
|
||||
{
|
||||
DWORD foregroundThreadID = GetWindowThreadProcessId(hWndForeground, nullptr);
|
||||
DWORD currentThreadID = GetCurrentThreadId();
|
||||
const DWORD foregroundThreadID = GetWindowThreadProcessId(hWndForeground, nullptr);
|
||||
const DWORD currentThreadID = GetCurrentThreadId();
|
||||
AttachThreadInput(currentThreadID, foregroundThreadID, TRUE);
|
||||
SetForegroundWindow(hWnd);
|
||||
AttachThreadInput(currentThreadID, foregroundThreadID, FALSE);
|
||||
@ -189,12 +185,6 @@ void ContextMenu::ShowMenu(POINT pos, MeterWindow* meterWindow)
|
||||
hWnd,
|
||||
nullptr);
|
||||
|
||||
if (meterWindow)
|
||||
{
|
||||
DestroyMenu(menu);
|
||||
}
|
||||
}
|
||||
|
||||
DestroyMenu(menu);
|
||||
|
||||
m_MenuActive = false;
|
||||
@ -258,8 +248,8 @@ HMENU ContextMenu::CreateSkinMenu(MeterWindow* meterWindow, int index, HMENU men
|
||||
};
|
||||
|
||||
HMENU skinMenu = MenuTemplate::CreateMenu(s_Menu, _countof(s_Menu), GetString);
|
||||
if (skinMenu)
|
||||
{
|
||||
if (!skinMenu) return nullptr;
|
||||
|
||||
// Tick the position
|
||||
HMENU settingsMenu = GetSubMenu(skinMenu, 4);
|
||||
if (settingsMenu)
|
||||
@ -267,7 +257,7 @@ HMENU ContextMenu::CreateSkinMenu(MeterWindow* meterWindow, int index, HMENU men
|
||||
HMENU posMenu = GetSubMenu(settingsMenu, 0);
|
||||
if (posMenu)
|
||||
{
|
||||
UINT checkPos = IDM_SKIN_NORMAL - (UINT)meterWindow->GetWindowZPosition();
|
||||
const UINT checkPos = IDM_SKIN_NORMAL - (UINT)meterWindow->GetWindowZPosition();
|
||||
CheckMenuRadioItem(posMenu, checkPos, checkPos, checkPos, MF_BYCOMMAND);
|
||||
|
||||
if (meterWindow->GetXFromRight()) CheckMenuItem(posMenu, IDM_SKIN_FROMRIGHT, MF_BYCOMMAND | MF_CHECKED);
|
||||
@ -397,7 +387,7 @@ HMENU ContextMenu::CreateSkinMenu(MeterWindow* meterWindow, int index, HMENU men
|
||||
|
||||
for (int i = 0; i < itemCount; ++i)
|
||||
{
|
||||
UINT state = GetMenuState(menu, i, MF_BYPOSITION);
|
||||
const UINT state = GetMenuState(menu, i, MF_BYPOSITION);
|
||||
if (state == 0xFFFFFFFF || (state & MF_POPUP) == 0) break;
|
||||
|
||||
WCHAR buffer[MAX_PATH];
|
||||
@ -451,7 +441,7 @@ HMENU ContextMenu::CreateSkinMenu(MeterWindow* meterWindow, int index, HMENU men
|
||||
}
|
||||
|
||||
// Build a sub-menu if more than three items
|
||||
size_t titleSize = cTitles.size();
|
||||
const size_t titleSize = cTitles.size();
|
||||
if (titleSize <= 3)
|
||||
{
|
||||
size_t position = 0;
|
||||
@ -464,7 +454,8 @@ HMENU ContextMenu::CreateSkinMenu(MeterWindow* meterWindow, int index, HMENU men
|
||||
}
|
||||
else
|
||||
{
|
||||
InsertMenu(skinMenu, position + 1, MF_BYPOSITION | MF_STRING, (index << 16) | (IDM_SKIN_CUSTOMCONTEXTMENU_FIRST + i), cTitles[i].c_str());
|
||||
const UINT_PTR id = (index << 16) | (IDM_SKIN_CUSTOMCONTEXTMENU_FIRST + i);
|
||||
InsertMenu(skinMenu, position + 1, MF_BYPOSITION | MF_STRING, id, cTitles[i].c_str());
|
||||
}
|
||||
|
||||
++position;
|
||||
@ -489,7 +480,8 @@ HMENU ContextMenu::CreateSkinMenu(MeterWindow* meterWindow, int index, HMENU men
|
||||
}
|
||||
else
|
||||
{
|
||||
AppendMenu(customMenu, MF_BYPOSITION | MF_STRING, (index << 16) | (IDM_SKIN_CUSTOMCONTEXTMENU_FIRST + i), cTitles[i].c_str());
|
||||
const UINT_PTR id = (index << 16) | (IDM_SKIN_CUSTOMCONTEXTMENU_FIRST + i);
|
||||
AppendMenu(customMenu, MF_BYPOSITION | MF_STRING, id, cTitles[i].c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@ -497,7 +489,6 @@ HMENU ContextMenu::CreateSkinMenu(MeterWindow* meterWindow, int index, HMENU men
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return skinMenu;
|
||||
}
|
||||
@ -532,7 +523,7 @@ int ContextMenu::CreateAllSkinsMenuRecursive(HMENU skinMenu, int index)
|
||||
// Add files
|
||||
{
|
||||
int fileIndex = 0;
|
||||
int fileCount = (int)skinFolder.files.size();
|
||||
const int fileCount = (int)skinFolder.files.size();
|
||||
for ( ; fileIndex < fileCount; ++fileIndex)
|
||||
{
|
||||
InsertMenu(subMenu, fileIndex, MF_STRING | MF_BYPOSITION, skinFolder.baseID + fileIndex, skinFolder.files[fileIndex].c_str());
|
||||
@ -568,8 +559,8 @@ void ContextMenu::CreateLayoutMenu(HMENU layoutMenu)
|
||||
|
||||
void ContextMenu::CreateMonitorMenu(HMENU monitorMenu, MeterWindow* meterWindow)
|
||||
{
|
||||
bool screenDefined = meterWindow->GetXScreenDefined();
|
||||
int screenIndex = meterWindow->GetXScreen();
|
||||
const bool screenDefined = meterWindow->GetXScreenDefined();
|
||||
const int screenIndex = meterWindow->GetXScreen();
|
||||
|
||||
// for the "Specified monitor" (@n)
|
||||
const size_t numOfMonitors = System::GetMonitorCount(); // intentional
|
||||
@ -593,11 +584,11 @@ void ContextMenu::CreateMonitorMenu(HMENU monitorMenu, MeterWindow* meterWindow)
|
||||
item += (*iter).monitorName;
|
||||
}
|
||||
|
||||
InsertMenu(monitorMenu,
|
||||
i + 2,
|
||||
MF_BYPOSITION | ((screenDefined && screenIndex == i) ? MF_CHECKED : MF_UNCHECKED) | ((!(*iter).active) ? MF_GRAYED : MF_ENABLED),
|
||||
ID_MONITOR_FIRST + i,
|
||||
item.c_str());
|
||||
const UINT flags =
|
||||
MF_BYPOSITION |
|
||||
((screenDefined && screenIndex == i) ? MF_CHECKED : MF_UNCHECKED) |
|
||||
((*iter).active ? MF_ENABLED : MF_GRAYED);
|
||||
InsertMenu(monitorMenu, i + 2, flags, ID_MONITOR_FIRST + i, item.c_str());
|
||||
}
|
||||
|
||||
if (!screenDefined)
|
||||
@ -620,8 +611,7 @@ void ContextMenu::ChangeSkinIndex(HMENU menu, int index)
|
||||
{
|
||||
if (index > 0)
|
||||
{
|
||||
int count = GetMenuItemCount(menu);
|
||||
|
||||
const int count = GetMenuItemCount(menu);
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
HMENU subMenu = GetSubMenu(menu, i);
|
||||
|
Loading…
Reference in New Issue
Block a user