HGENMENU CMraProto::CListCreateMenu(LONG lPosition, LONG lPopupPosition, BOOL bIsMain, const IconItem *pgdiItems, size_t dwCount, HGENMENU *hResult) { if (!pgdiItems || !dwCount || !hResult) return NULL; char szServiceFunction[MAX_PATH]; strncpy(szServiceFunction, m_szModuleName, sizeof(szServiceFunction)); char *pszServiceFunctionName = szServiceFunction + strlen(m_szModuleName); CLISTMENUITEM mi = { sizeof(mi) }; HGENMENU hRootMenu, (*fnAddFunc)(CLISTMENUITEM*); if (bIsMain) { fnAddFunc = Menu_AddProtoMenuItem; hRootMenu = MO_GetProtoRootMenu(m_szModuleName); if (hRootMenu == NULL) { mi.ptszName = m_tszUserName; mi.hParentMenu = HGENMENU_ROOT; mi.flags = CMIF_ROOTPOPUP | CMIF_TCHAR | CMIF_KEEPUNTRANSLATED; mi.hIcon = g_hMainIcon; hRootMenu = Menu_AddProtoMenuItem(&mi); } mi.position = 20003; mi.hParentMenu = hRootMenu; mi.flags = CMIF_ROOTHANDLE; } else { fnAddFunc = Menu_AddContactMenuItem; mi.position = lPosition; mi.flags = CMIF_ROOTPOPUP; } mi.pszName = LPGEN("Services..."); mi.hIcon = g_hMainIcon; hRootMenu = fnAddFunc(&mi); mi.flags = CMIF_CHILDPOPUP; mi.hParentMenu = hRootMenu; mi.popupPosition = lPopupPosition; mi.pszService = szServiceFunction; for (size_t i = 0; i < dwCount; i++) { strcpy(pszServiceFunctionName, pgdiItems[i].szName); mi.position = int(lPosition + i); mi.icolibItem = pgdiItems[i].hIcolib; mi.pszName = pgdiItems[i].szDescr; hResult[i] = fnAddFunc(&mi); } return hRootMenu; }
HGENMENU CMraProto::CListCreateMenu(LONG lPosition, LONG lPopupPosition, BOOL bIsMain, const IconItem *pgdiItems, size_t dwCount, HGENMENU *hResult) { if (!pgdiItems || !dwCount || !hResult) return NULL; char szServiceFunction[MAX_PATH]; CMenuItem mi; HGENMENU hRootMenu, (__stdcall *fnAddFunc)(TMO_MenuItem*, const char*); if (bIsMain) { fnAddFunc = Menu_AddProtoMenuItem; hRootMenu = Menu_GetProtocolRoot(this); if (hRootMenu == NULL) { mi.name.t = m_tszUserName; mi.flags = CMIF_TCHAR | CMIF_KEEPUNTRANSLATED; mi.hIcolibItem = g_hMainIcon; hRootMenu = Menu_AddProtoMenuItem(&mi); } mi.position = 20003; mi.root = hRootMenu; } else { fnAddFunc = Menu_AddContactMenuItem; mi.position = lPosition; } SET_UID(mi, 0x83C8B6A7, 0xEC0D, 0x41D6, 0x8A, 0x0E, 0xAC, 0x90, 0x8C, 0xEE, 0xAF, 0xFE); mi.flags = 0; mi.name.a = LPGEN("Services..."); mi.hIcolibItem = g_hMainIcon; hRootMenu = fnAddFunc(&mi, m_szModuleName); UNSET_UID(mi); mi.flags = CMIF_SYSTEM; mi.root = hRootMenu; mi.pszService = szServiceFunction; for (size_t i = 0; i < dwCount; i++) { mi.pszService = pgdiItems[i].szName; mi.position = int(lPosition + i); mi.hIcolibItem = pgdiItems[i].hIcolib; mi.name.a = pgdiItems[i].szDescr; hResult[i] = fnAddFunc(&mi, m_szModuleName); Menu_ConfigureItem(hResult[i], MCI_OPT_EXECPARAM, lPopupPosition); } return hRootMenu; }