summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mir_app/src/clistmenus.cpp14
-rw-r--r--src/mir_app/src/genmenu.cpp34
-rw-r--r--src/mir_app/src/mir_app.def2
-rw-r--r--src/mir_app/src/mir_app64.def2
4 files changed, 38 insertions, 14 deletions
diff --git a/src/mir_app/src/clistmenus.cpp b/src/mir_app/src/clistmenus.cpp
index 9baf333882..d6ada2b63d 100644
--- a/src/mir_app/src/clistmenus.cpp
+++ b/src/mir_app/src/clistmenus.cpp
@@ -605,20 +605,6 @@ INT_PTR FreeOwnerDataStatusMenu(WPARAM, LPARAM lParam)
/////////////////////////////////////////////////////////////////////////////////////////
// Other menu functions
-MIR_APP_DLL(void) Menu_ShowItem(HGENMENU hMenuItem, bool bShow)
-{
- TMO_IntMenuItem *pimi = MO_GetIntMenuItem(hMenuItem);
- if (pimi == NULL)
- return;
-
- int flags = pimi->mi.flags;
- if (bShow)
- flags &= ~CMIF_HIDDEN;
- else
- flags |= CMIF_HIDDEN;
- Menu_ModifyItem(hMenuItem, NULL, INVALID_HANDLE_VALUE, flags);
-}
-
INT_PTR MenuProcessCommand(WPARAM wParam, LPARAM lParam)
{
WORD cmd = LOWORD(wParam);
diff --git a/src/mir_app/src/genmenu.cpp b/src/mir_app/src/genmenu.cpp
index ef63bd933f..05babf2759 100644
--- a/src/mir_app/src/genmenu.cpp
+++ b/src/mir_app/src/genmenu.cpp
@@ -278,6 +278,40 @@ MIR_APP_DLL(HGENMENU) Menu_GetDefaultItem(HGENMENU hMenu)
/////////////////////////////////////////////////////////////////////////////////////////
+static void Menu_SetItemFlags(HGENMENU hMenuItem, bool bSet, int mask)
+{
+ TMO_IntMenuItem *pimi = MO_GetIntMenuItem(hMenuItem);
+ if (pimi == NULL)
+ return;
+
+ int flags = pimi->mi.flags;
+ if (bSet)
+ flags |= mask;
+ else
+ flags &= ~mask;
+
+ mir_cslock lck(csMenuHook);
+ int oldflags = (pimi->mi.flags & CMIF_ROOTHANDLE);
+ pimi->mi.flags = flags | oldflags;
+}
+
+MIR_APP_DLL(void) Menu_EnableItem(HGENMENU hMenuItem, bool bEnable)
+{
+ Menu_SetItemFlags(hMenuItem, !bEnable, CMIF_GRAYED);
+}
+
+MIR_APP_DLL(void) Menu_ShowItem(HGENMENU hMenuItem, bool bShow)
+{
+ Menu_SetItemFlags(hMenuItem, !bShow, CMIF_HIDDEN);
+}
+
+MIR_APP_DLL(void) Menu_SetChecked(HGENMENU hMenuItem, bool bSet)
+{
+ Menu_SetItemFlags(hMenuItem, bSet, CMIF_CHECKED);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
MIR_APP_DLL(int) Menu_ModifyItem(HGENMENU hMenuItem, const TCHAR *ptszName, HANDLE hIcon, int iFlags)
{
if (!bIsGenMenuInited)
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def
index ee225cae3c..4b2e9ec4fe 100644
--- a/src/mir_app/src/mir_app.def
+++ b/src/mir_app/src/mir_app.def
@@ -218,3 +218,5 @@ Menu_GetItemInfo @215
Menu_ProcessHotKey @216
Menu_DrawItem @217
Menu_MeasureItem @218
+Menu_EnableItem @219
+Menu_SetChecked @220
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def
index e0a756b14f..bb17f0e413 100644
--- a/src/mir_app/src/mir_app64.def
+++ b/src/mir_app/src/mir_app64.def
@@ -218,3 +218,5 @@ Menu_GetItemInfo @215
Menu_ProcessHotKey @216
Menu_DrawItem @217
Menu_MeasureItem @218
+Menu_EnableItem @219
+Menu_SetChecked @220