diff options
author | George Hazan <george.hazan@gmail.com> | 2013-04-05 16:53:36 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-04-05 16:53:36 +0000 |
commit | 6c01981a8452577f3751298c7cdbe59b3ae81d51 (patch) | |
tree | 197761c10a3a206f98745e9341dd516c784e99bb | |
parent | 297626e55974e9082f0fd76b98050fc291b1e3f3 (diff) |
MS_CLIST_SHOWHIDEMENUITEM - new simplified service for the menus items' hiding/showing
git-svn-id: http://svn.miranda-ng.org/main/trunk@4318 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | include/delphi/m_clist.inc | 16 | ||||
-rw-r--r-- | include/m_clist.h | 15 | ||||
-rw-r--r-- | src/modules/clist/clistmenus.cpp | 29 |
3 files changed, 48 insertions, 12 deletions
diff --git a/include/delphi/m_clist.inc b/include/delphi/m_clist.inc index db69c8050b..5fe6680289 100644 --- a/include/delphi/m_clist.inc +++ b/include/delphi/m_clist.inc @@ -148,6 +148,14 @@ const MS_CLIST_MODIFYMENUITEM:PAnsiChar = 'CList/ModifyMenuItem';
{
+ wParam : (HGENMENU)hMenuItem
+ lParam : (BOOL) enable = TRUE, disable = FALSE
+ Notes : changes menu item's visibility
+ Version: v0.94.2+
+ }
+ MS_CLIST_SHOWHIDEMENUITEM:PAnsiChar = 'CList/ShowHideMenuItem';
+
+ {
wParam : HCONTACT
lParam : 0
Affect : the context menu for a contact is about to be built, see notes
@@ -374,11 +382,11 @@ const to ensure that WM_COMMAND was realy from clist menu not from other menu
it is reserved range of menu ids from CLISTMENUIDMIN to CLISTMENUIDMAX
the menu items with ids outside from such range will not be processed by service.
- Moreover if you process WM_COMMAND youself and your window contains self menu
+ Moreover if you process WM_COMMAND youself and your window contains self menu
please be sure that you will not call service for non-clist menu items.
The simplest way is to ensure that your menus are not use item ids from such range.
Otherwise, you HAVE TO distinguish WM_COMMAND from clist menus and from your
- internal menu and DO NOT call MS_CLIST_MENUPROCESSCOMMAND for non clist menus.
+ internal menu and DO NOT call MS_CLIST_MENUPROCESSCOMMAND for non clist menus.
}
MPCF_CONTACTMENU = 1; // test commands from a contact menu
MPCF_MAINMENU = 2; // test commands from the main menu
@@ -467,8 +475,8 @@ const {
sent when the group get modified (created, renamed or deleted)
- or contact is moving from group to group
- wParam=hContact - NULL if operation on group
+ or contact is moving from group to group
+ wParam=hContact - NULL if operation on group
lParam=pointer to CLISTGROUPCHANGE
}
type
diff --git a/include/m_clist.h b/include/m_clist.h index 8890462108..bcf0a3aaa7 100644 --- a/include/m_clist.h +++ b/include/m_clist.h @@ -175,7 +175,7 @@ __forceinline HGENMENU Menu_AddProtoMenuItem(CLISTMENUITEM *mi) }
//modify an existing menu item v0.1.0.1+
-//wParam = (WPARAM)(HANDLE)hMenuItem
+//wParam = (WPARAM)(HGENMENU)hMenuItem
//lParam = (LPARAM)(CLISTMENUITEM*)&clmi
//returns 0 on success, nonzero on failure
//hMenuItem will have been returned by clist/add*menuItem
@@ -188,6 +188,19 @@ __forceinline HGENMENU Menu_AddProtoMenuItem(CLISTMENUITEM *mi) #define CMIM_ALL 0xF0000000
#define MS_CLIST_MODIFYMENUITEM "CList/ModifyMenuItem"
+__forceinline void Menu_ModifyItem(HGENMENU hMenuItem, CLISTMENUITEM *clmi)
+{ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuItem, (LPARAM)clmi);
+}
+
+//changes menu item's visibility v0.94.2+
+//wParam = (WPARAM)(HGENMENU)hMenuItem
+//lParam = (BOOL) enable = TRUE, disable = FALSE
+#define MS_CLIST_SHOWHIDEMENUITEM "CList/ShowHideMenuItem"
+
+__forceinline void Menu_ShowItem(HGENMENU hMenuItem, BOOL bShow)
+{ CallService(MS_CLIST_SHOWHIDEMENUITEM, (WPARAM)hMenuItem, bShow);
+}
+
//the context menu for a contact is about to be built v0.1.0.1+
//wParam = (WPARAM)(HANDLE)hContact
//lParam = 0
diff --git a/src/modules/clist/clistmenus.cpp b/src/modules/clist/clistmenus.cpp index a8b4bfd0c3..2039e7ca7f 100644 --- a/src/modules/clist/clistmenus.cpp +++ b/src/modules/clist/clistmenus.cpp @@ -657,6 +657,22 @@ INT_PTR FreeOwnerDataStatusMenu(WPARAM, LPARAM lParam) /////////////////////////////////////////////////////////////////////////////////////////
// Other menu functions
+static INT_PTR ShowHideMenuItem(WPARAM wParam, LPARAM lParam)
+{
+ PMO_IntMenuItem pimi = MO_GetIntMenuItem((HGENMENU)wParam);
+ if (pimi == NULL)
+ return 1;
+
+ TMO_MenuItem tmi = { sizeof(tmi) };
+ tmi.flags = CMIM_FLAGS + pimi->mi.flags;
+ if (lParam)
+ tmi.flags &= ~CMIF_HIDDEN;
+ else
+ tmi.flags |= CMIF_HIDDEN;
+
+ return MO_ModifyMenuItem((PMO_IntMenuItem)wParam, &tmi);
+}
+
//wparam MenuItemHandle
static INT_PTR ModifyCustomMenuItem(WPARAM wParam, LPARAM lParam)
{
@@ -694,17 +710,15 @@ INT_PTR MenuProcessCommand(WPARAM wParam, LPARAM lParam) BOOL FindMenuHanleByGlobalID(HMENU hMenu, PMO_IntMenuItem id, MenuItemData* itdat)
{
- int i;
- PMO_IntMenuItem pimi;
- MENUITEMINFO mii = {0};
- BOOL inSub = FALSE;
-
if ( !itdat)
return FALSE;
+ BOOL inSub = FALSE;
+
+ MENUITEMINFO mii = {0};
mii.cbSize = MENUITEMINFO_V4_SIZE;
mii.fMask = MIIM_SUBMENU | MIIM_DATA;
- for (i = GetMenuItemCount(hMenu)-1; i >= 0; i--) {
+ for (int i = GetMenuItemCount(hMenu)-1; i >= 0; i--) {
GetMenuItemInfo(hMenu, i, TRUE, &mii);
if (mii.fType == MFT_SEPARATOR)
continue;
@@ -714,7 +728,7 @@ BOOL FindMenuHanleByGlobalID(HMENU hMenu, PMO_IntMenuItem id, MenuItemData* itda if (inSub)
return inSub;
- pimi = MO_GetIntMenuItem((HGENMENU)mii.dwItemData);
+ PMO_IntMenuItem pimi = MO_GetIntMenuItem((HGENMENU)mii.dwItemData);
if (pimi != NULL) {
if (pimi == id) {
itdat->OwnerMenu = hMenu;
@@ -1302,6 +1316,7 @@ void InitCustomMenus(void) CreateServiceFunction(MS_CLIST_MENUBUILDCONTACT, BuildContactMenu);
CreateServiceFunction(MS_CLIST_REMOVECONTACTMENUITEM, RemoveContactMenuItem);
+ CreateServiceFunction(MS_CLIST_SHOWHIDEMENUITEM, ShowHideMenuItem);
CreateServiceFunction(MS_CLIST_MODIFYMENUITEM, ModifyCustomMenuItem);
CreateServiceFunction(MS_CLIST_MENUMEASUREITEM, MeasureMenuItem);
CreateServiceFunction(MS_CLIST_MENUDRAWITEM, DrawMenuItem);
|