summaryrefslogtreecommitdiff
path: root/protocols/MRA/Mra_functions.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-06-24 22:50:32 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-06-24 22:50:32 +0000
commite1e2063eee00d455fc54f64363b3cc535edf1750 (patch)
tree22ebcad764c23e84509b0d6bb30715db720a97dc /protocols/MRA/Mra_functions.cpp
parent843145196e0aa520ba23b6f6cffc393118bcf46a (diff)
fix for menu creation
git-svn-id: http://svn.miranda-ng.org/main/trunk@620 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/MRA/Mra_functions.cpp')
-rw-r--r--protocols/MRA/Mra_functions.cpp86
1 files changed, 45 insertions, 41 deletions
diff --git a/protocols/MRA/Mra_functions.cpp b/protocols/MRA/Mra_functions.cpp
index 4764ded024..d96e15f9a0 100644
--- a/protocols/MRA/Mra_functions.cpp
+++ b/protocols/MRA/Mra_functions.cpp
@@ -1393,47 +1393,51 @@ return(dwRetErrorCode);
-void CListCreateMenu(LONG lPosition,LONG lPopupPosition,HANDLE hMainIcon,LPSTR pszContactOwner,BOOL bIsMain,const GUI_DISPLAY_ITEM *pgdiItems,HANDLE *hIcoLibIcons,SIZE_T dwCount,HANDLE *hResult)
-{
- if (pgdiItems && hIcoLibIcons && dwCount && hResult)
- {
- char szServiceFunction[MAX_PATH],*pszServiceFunctionName;
- CLISTMENUITEM mi={0};
-
- memmove(szServiceFunction,PROTOCOL_NAMEA,PROTOCOL_NAME_SIZE);
- pszServiceFunctionName=szServiceFunction+PROTOCOL_NAME_LEN;
-
- mi.cbSize=sizeof(mi);
- mi.popupPosition=lPopupPosition;
- mi.ptszPopupName=PROTOCOL_DISPLAY_NAMEW;
- mi.pszService=szServiceFunction;
- mi.flags=(CMIF_UNICODE|CMIF_ICONFROMICOLIB);
-
- for (SIZE_T i=0;i<dwCount;i++)
- {
- memmove(pszServiceFunctionName,pgdiItems[i].lpszName,(lstrlenA(pgdiItems[i].lpszName)+1));
- if (pgdiItems[i].lpFunc)
- CreateServiceFunction(szServiceFunction,pgdiItems[i].lpFunc);
- mi.position=(lPosition+i);
- mi.icolibItem=hIcoLibIcons[i];
- mi.ptszName=pgdiItems[i].lpwszDescr;
-
- if (i==0 && hMainIcon)
- {
- mi.icolibItem=hMainIcon;
- mi.flags=(CMIF_UNICODE);
- }
-
- hResult[i] = (bIsMain) ? Menu_AddProtoMenuItem(&mi) : Menu_AddContactMenuItem(&mi);
-
- if (i==0 && hMainIcon)
- {
- mi.flags=CMIM_FLAGS|CMIM_ICON|CMIF_ICONFROMICOLIB;
- mi.icolibItem=hIcoLibIcons[i];
- CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)hResult[i],(LPARAM)&mi);
- mi.flags=(CMIF_UNICODE|CMIF_ICONFROMICOLIB);
- }
- }
+void CListCreateMenu(LONG lPosition,LONG lPopupPosition,HICON hMainIcon,LPSTR pszContactOwner,BOOL bIsMain,const GUI_DISPLAY_ITEM *pgdiItems,HANDLE *hIcoLibIcons,SIZE_T dwCount,HANDLE *hResult)
+{
+ if (!pgdiItems || !hIcoLibIcons || !dwCount || !hResult)
+ return;
+
+ char szServiceFunction[MAX_PATH],*pszServiceFunctionName;
+ memmove(szServiceFunction, PROTOCOL_NAMEA, PROTOCOL_NAME_SIZE);
+ pszServiceFunctionName = szServiceFunction + PROTOCOL_NAME_LEN;
+
+ CLISTMENUITEM mi = {0};
+ mi.cbSize = sizeof(mi);
+
+ HGENMENU (*fnAddFunc)(CLISTMENUITEM*);
+ if (bIsMain) {
+ fnAddFunc = Menu_AddProtoMenuItem;
+
+ HGENMENU hRootMenu = MO_GetProtoRootMenu(PROTOCOL_NAMEA);
+ if (hRootMenu == NULL) {
+ mi.ptszName = PROTOCOL_NAMEW;
+ mi.position = -1999901008;
+ mi.hParentMenu = HGENMENU_ROOT;
+ mi.flags = CMIF_ROOTPOPUP | CMIF_TCHAR | CMIF_KEEPUNTRANSLATED;
+ mi.hIcon = hMainIcon;
+ hRootMenu = Menu_AddProtoMenuItem(&mi);
+ }
+ mi.hParentMenu = hRootMenu;
+ mi.flags = CMIF_UNICODE | CMIF_ICONFROMICOLIB | CMIF_CHILDPOPUP;
+ }
+ else {
+ fnAddFunc = Menu_AddContactMenuItem;
+ mi.ptszPopupName = PROTOCOL_DISPLAY_NAMEW;
+ mi.flags = CMIF_UNICODE | CMIF_ICONFROMICOLIB;
+ }
+
+ mi.popupPosition = lPopupPosition;
+ mi.pszService = szServiceFunction;
+
+ for (size_t i=0; i < dwCount; i++) {
+ memmove(pszServiceFunctionName, pgdiItems[i].lpszName, lstrlenA(pgdiItems[i].lpszName)+1);
+ if (pgdiItems[i].lpFunc)
+ CreateServiceFunction(szServiceFunction,pgdiItems[i].lpFunc);
+ mi.position = lPosition + i;
+ mi.icolibItem = hIcoLibIcons[i];
+ mi.ptszName = pgdiItems[i].lpwszDescr;
+ hResult[i] = fnAddFunc(&mi);
}
}