From 30707c980d1560b358dbf2671a4d2a26a1e8173c Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 28 Nov 2012 21:45:37 +0000 Subject: various menu initialization quirks git-svn-id: http://svn.miranda-ng.org/main/trunk@2552 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/ContactsPlus/src/main.cpp | 82 ++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 44 deletions(-) (limited to 'plugins/ContactsPlus/src') diff --git a/plugins/ContactsPlus/src/main.cpp b/plugins/ContactsPlus/src/main.cpp index 585575f77b..c64acaf38a 100644 --- a/plugins/ContactsPlus/src/main.cpp +++ b/plugins/ContactsPlus/src/main.cpp @@ -154,60 +154,54 @@ static bool CheckContactsServiceSupport(const char* szProto) static int HookPreBuildContactMenu(WPARAM wParam, LPARAM lParam) { - HANDLE hContact = (HANDLE)wParam; - char* szProto =GetContactProto(hContact); - int bVisible = FALSE; - - if (szProto && CheckContactsServiceSupport(szProto)) - { // known protocol, protocol supports contacts sending - // check the selected contact if it supports contacts receive - if (CallProtoService(szProto, PS_GETCAPS, PFLAG_MAXCONTACTSPERPACKET, (LPARAM)hContact)) - bVisible = TRUE; - } - - { // update contact menu item's visibility - CLISTMENUITEM mi = {0}; - - mi.cbSize = sizeof(mi); - if (bVisible) - mi.flags = CMIM_FLAGS; - else - mi.flags = CMIM_FLAGS | CMIF_HIDDEN; - - CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hContactMenuItem, (LPARAM)&mi); - } - - return 0; + HANDLE hContact = (HANDLE)wParam; + char* szProto =GetContactProto(hContact); + int bVisible = FALSE; + + if (szProto && CheckContactsServiceSupport(szProto)) { + // known protocol, protocol supports contacts sending + // check the selected contact if it supports contacts receive + if (CallProtoService(szProto, PS_GETCAPS, PFLAG_MAXCONTACTSPERPACKET, (LPARAM)hContact)) + bVisible = TRUE; + } + + // update contact menu item's visibility + CLISTMENUITEM mi = { sizeof(mi) }; + if (bVisible) + mi.flags = CMIM_FLAGS; + else + mi.flags = CMIM_FLAGS | CMIF_HIDDEN; + + CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hContactMenuItem, (LPARAM)&mi); + return 0; } static int HookModulesLoaded(WPARAM wParam, LPARAM lParam) { - char* modules[2] = {0}; - WCHAR tmp[MAX_PATH]; + char* modules[2] = {0}; + WCHAR tmp[MAX_PATH]; - modules[0] = MODULENAME; - CallService("DBEditorpp/RegisterModule",(WPARAM)modules,(LPARAM)1); + modules[0] = MODULENAME; + CallService("DBEditorpp/RegisterModule",(WPARAM)modules,(LPARAM)1); - CLISTMENUITEM mi = {0}; - mi.cbSize = sizeof(mi); - mi.ptszName = SRCTranslateT("Contacts", tmp); - mi.position = -2000009990; //position in menu - mi.flags = CMIF_KEEPUNTRANSLATED; - if (g_UnicodeCore) - mi.flags |= CMIF_UNICODE; - mi.pszService = MS_CONTACTS_SEND; - mi.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_CONTACTS)); - hContactMenuItem = Menu_AddContactMenuItem(&mi); + CLISTMENUITEM mi = { sizeof(mi) }; + mi.ptszName = SRCTranslateT("Contacts", tmp); + mi.position = -2000009990; //position in menu + mi.flags = CMIF_KEEPUNTRANSLATED; + if (g_UnicodeCore) + mi.flags |= CMIF_UNICODE; + mi.pszService = MS_CONTACTS_SEND; + mi.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_CONTACTS)); + hContactMenuItem = Menu_AddContactMenuItem(&mi); - hHookPreBuildContactMenu = HookEvent(ME_CLIST_PREBUILDCONTACTMENU, HookPreBuildContactMenu); + hHookPreBuildContactMenu = HookEvent(ME_CLIST_PREBUILDCONTACTMENU, HookPreBuildContactMenu); - ghSendWindowList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0); // no need to destroy this - ghRecvWindowList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0); // no need to destroy this + ghSendWindowList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0); // no need to destroy this + ghRecvWindowList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0); // no need to destroy this - - ProcessUnreadEvents(); - return 0; + ProcessUnreadEvents(); + return 0; } -- cgit v1.2.3