diff options
author | George Hazan <george.hazan@gmail.com> | 2012-11-28 21:45:37 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-11-28 21:45:37 +0000 |
commit | 30707c980d1560b358dbf2671a4d2a26a1e8173c (patch) | |
tree | 74aee5adaaac976e1398274ca64c5461a60f1feb /plugins/Clist_modern | |
parent | 335ec43a4bfdcbbd0b2257037f1f3e0553d89076 (diff) |
various menu initialization quirks
git-svn-id: http://svn.miranda-ng.org/main/trunk@2552 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Clist_modern')
-rw-r--r-- | plugins/Clist_modern/src/modern_clistmenus.cpp | 5 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_clisttray.cpp | 6 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_clui.cpp | 6 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_cluiframes.cpp | 40 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_groupmenu.cpp | 88 |
5 files changed, 41 insertions, 104 deletions
diff --git a/plugins/Clist_modern/src/modern_clistmenus.cpp b/plugins/Clist_modern/src/modern_clistmenus.cpp index ba4e787b02..0c6175e7cc 100644 --- a/plugins/Clist_modern/src/modern_clistmenus.cpp +++ b/plugins/Clist_modern/src/modern_clistmenus.cpp @@ -75,7 +75,6 @@ static HANDLE hOnContactMenuBuild_FAV = NULL; static int FAV_OnContactMenuBuild(WPARAM wParam,LPARAM lParam)
{
- CLISTMENUITEM mi;
BOOL NeedFree = FALSE;
BYTE bContactRate = db_get_b((HANDLE)wParam, "CList", "Rate",0);
//if (hFavoriteContactMenu)
@@ -103,9 +102,7 @@ static int FAV_OnContactMenuBuild(WPARAM wParam,LPARAM lParam) int i;
TCHAR * name = NULL;
-
- memset(&mi,0,sizeof(mi));
- mi.cbSize = sizeof(mi);
+ CLISTMENUITEM mi = { sizeof(mi) };
mi.hIcon = CLUI_LoadIconFromExternalFile("clisticons.dll",8,TRUE,TRUE,iconsName[bContactRate],"Contact List",Translate(iconsName[bContactRate]),-IDI_FAVORITE_0 - bContactRate, &NeedFree);
mi.pszPopupName = (char *)-1;
mi.position = 0;
diff --git a/plugins/Clist_modern/src/modern_clisttray.cpp b/plugins/Clist_modern/src/modern_clisttray.cpp index 4ac629d55b..03414ab7f9 100644 --- a/plugins/Clist_modern/src/modern_clisttray.cpp +++ b/plugins/Clist_modern/src/modern_clisttray.cpp @@ -641,10 +641,7 @@ void InitTrayMenus(void) {
//add exit command to menu
- CLISTMENUITEM mi;
-
- memset(&mi,0,sizeof(mi));
- mi.cbSize = sizeof(mi);
+ CLISTMENUITEM mi = { sizeof(mi) };
mi.position = 900000;
mi.pszService = "CloseAction";
mi.pszName = LPGEN("E&xit");
@@ -673,7 +670,6 @@ void InitTrayMenus(void) AddTrayMenuItem(0,(LPARAM)&mi);
DestroyIcon_protect(mi.hIcon);
-
memset(&mi,0,sizeof(mi));
mi.cbSize = sizeof(mi);
mi.position = 300000;
diff --git a/plugins/Clist_modern/src/modern_clui.cpp b/plugins/Clist_modern/src/modern_clui.cpp index b0a9ffee51..6892cbf104 100644 --- a/plugins/Clist_modern/src/modern_clui.cpp +++ b/plugins/Clist_modern/src/modern_clui.cpp @@ -100,10 +100,10 @@ int CLUI::OnEvent_ContactMenuPreBuild(WPARAM wParam, LPARAM lParam) TCHAR cls[128];
HANDLE hItem;
HWND hwndClist = GetFocus();
- CLISTMENUITEM mi;
+
if (MirandaExiting()) return 0;
- ZeroMemory(&mi,sizeof(mi));
- mi.cbSize = sizeof(mi);
+
+ CLISTMENUITEM mi = { sizeof(mi) };
mi.flags = CMIM_FLAGS;
GetClassName(hwndClist,cls,SIZEOF(cls));
hwndClist = (!lstrcmp(CLISTCONTROL_CLASS,cls))?hwndClist:pcli->hwndContactList;
diff --git a/plugins/Clist_modern/src/modern_cluiframes.cpp b/plugins/Clist_modern/src/modern_cluiframes.cpp index 2b78349096..37c0a574e0 100644 --- a/plugins/Clist_modern/src/modern_cluiframes.cpp +++ b/plugins/Clist_modern/src/modern_cluiframes.cpp @@ -837,8 +837,7 @@ static HMENU CLUIFramesCreateMenuForFrame(int frameid,int root,int popuppos,HGEN if (_fCluiFramesModuleNotStarted)
return NULL;
- CLISTMENUITEM mi = { 0 };
- mi.cbSize = sizeof(mi);
+ CLISTMENUITEM mi = { sizeof(mi) };
mi.flags = CMIF_ICONFROMICOLIB;
mi.pszPopupName = (char *)root;
mi.popupPosition = frameid;
@@ -1006,15 +1005,12 @@ static int ModifyMItem(WPARAM wParam,LPARAM lParam) static int CLUIFramesModifyContextMenuForFrame(WPARAM wParam,LPARAM lParam)
{
- int pos;
- CLISTMENUITEM mi;
/* HOOK */
if (MirandaExiting()) return 0;
if (_fCluiFramesModuleNotStarted) return -1;
- pos = id2pos(wParam);
+ int pos = id2pos(wParam);
if (pos >= 0 && pos < g_nFramesCount) {
- memset(&mi,0,sizeof(mi));
- mi.cbSize = sizeof(mi);
+ CLISTMENUITEM mi = { sizeof(mi) };
mi.flags = CMIM_FLAGS|CMIM_NAME|CMIF_CHILDPOPUP|CMIF_TCHAR;
if (g_pfwFrames[pos].visible) mi.flags |= CMIF_CHECKED;
mi.ptszName = g_pfwFrames[pos].TitleBar.tbname ? g_pfwFrames[pos].TitleBar.tbname : g_pfwFrames[pos].Name;
@@ -1061,18 +1057,12 @@ static int CLUIFramesModifyContextMenuForFrame(WPARAM wParam,LPARAM lParam) static int CLUIFramesModifyMainMenuItems(WPARAM wParam,LPARAM lParam)
{
//hiword(wParam) = frameid,loword(wParam) = flag
- int pos;
- CLISTMENUITEM mi;
- //TMO_MenuItem tmi;
-
if (_fCluiFramesModuleNotStarted) return -1;
-
- pos = id2pos(wParam);
+ int pos = id2pos(wParam);
if (pos >= 0 && pos < g_nFramesCount) {
- memset(&mi,0,sizeof(mi));
- mi.cbSize = sizeof(mi);
+ CLISTMENUITEM mi = { sizeof(mi) };
mi.flags = CMIM_FLAGS|CMIM_NAME|CMIF_CHILDPOPUP|CMIF_TCHAR;
if (g_pfwFrames[pos].visible) mi.flags |= CMIF_CHECKED;
mi.ptszName = g_pfwFrames[pos].TitleBar.tbname ? g_pfwFrames[pos].TitleBar.tbname : g_pfwFrames[pos].Name;
@@ -1108,23 +1098,6 @@ static int CLUIFramesModifyMainMenuItems(WPARAM wParam,LPARAM lParam) if (g_pfwFrames[pos].align&alBottom) mi.flags |= CMIF_CHECKED;
CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)g_pfwFrames[pos].MenuHandles.MIAlignBottom,(LPARAM)&mi);
- /*
- mi.flags = CMIM_FLAGS|CMIF_CHILDPOPUP|((Frames[pos].align&alClient)?CMIF_GRAYED:0);
- if (Frames[pos].align&alTop) mi.flags |= CMIF_CHECKED;
- ModifyMItem((WPARAM)contMIAlignTop,(LPARAM)&mi);
-
- mi.flags = CMIM_FLAGS|CMIF_CHILDPOPUP|CMIF_GRAYED;
- if (Frames[pos].align&alClient) mi.flags |= CMIF_CHECKED;
- ModifyMItem((WPARAM)contMIAlignClient,(LPARAM)&mi);
-
- mi.flags = CMIM_FLAGS|CMIF_CHILDPOPUP|((Frames[pos].align&alClient)?CMIF_GRAYED:0);
- if (Frames[pos].align&alBottom) mi.flags |= CMIF_CHECKED;
- ModifyMItem((WPARAM)contMIAlignBottom,(LPARAM)&mi);
-
- */
-
-
-
mi.flags = CMIM_FLAGS|CMIF_CHILDPOPUP;
if (g_pfwFrames[pos].collapsed) mi.flags |= CMIF_CHECKED;
if ((!g_pfwFrames[pos].visible) || g_pfwFrames[pos].Locked || (pos == CLUIFramesGetalClientFrame())) mi.flags |= CMIF_GRAYED;
@@ -1768,9 +1741,8 @@ static int CLUIFramesLoadMainMenu() _hmiRoot = (HGENMENU)-1;
}
- CLISTMENUITEM mi = { 0 };
- mi.cbSize = sizeof(mi);
// create root menu
+ CLISTMENUITEM mi = { sizeof(mi) };
mi.flags = CMIF_ICONFROMICOLIB | CMIF_ROOTHANDLE;
mi.icolibItem = LoadSkinnedIconHandle(SKINICON_OTHER_MIRANDA);
mi.position = 3000090000;
diff --git a/plugins/Clist_modern/src/modern_groupmenu.cpp b/plugins/Clist_modern/src/modern_groupmenu.cpp index d11337f3ed..e9c5d5791d 100644 --- a/plugins/Clist_modern/src/modern_groupmenu.cpp +++ b/plugins/Clist_modern/src/modern_groupmenu.cpp @@ -214,11 +214,9 @@ INT_PTR CreateGroupHelper(WPARAM wParam,LPARAM lParam) static int OnBuildGroupMenu(WPARAM wParam,LPARAM lParam)
{
- CLISTMENUITEM mi;
- if (MirandaExiting()) return 0;
-
- ZeroMemory(&mi,sizeof(mi));
- mi.cbSize = sizeof(mi);
+ if (MirandaExiting()) return 0;
+
+ CLISTMENUITEM mi = { sizeof(mi) };
mi.flags = CMIM_FLAGS | (db_get_b(NULL,"CList","HideOffline",SETTING_HIDEOFFLINE_DEFAULT)?CMIF_CHECKED:0);
CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hHideOfflineUsersMenuItem, (LPARAM)&mi);
@@ -238,27 +236,24 @@ static int OnBuildGroupMenu(WPARAM wParam,LPARAM lParam) CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hDisableGroupsMenuItem, (LPARAM)&mi);
return 0;
-};
+}
int static OnIconLibIconChanged(WPARAM wParam,LPARAM lParam)
{
- HICON hicon;
- CLISTMENUITEM clmi = {0};
+ if (MirandaExiting()) return 0;
+
BOOL needFree;
- if (MirandaExiting()) return 0;
- hicon = CLUI_LoadIconFromExternalFile("clisticons.dll",2,TRUE,FALSE,"NewGroup","Contact List","New Group",-IDI_NEWGROUP2,&needFree);
+ HICON hicon = CLUI_LoadIconFromExternalFile("clisticons.dll",2,TRUE,FALSE,"NewGroup","Contact List","New Group",-IDI_NEWGROUP2,&needFree);
NewGroupIconidx = ImageList_ReplaceIcon(hCListImages,NewGroupIconidx,hicon);
if (needFree) DestroyIcon_protect(hicon);
- clmi.cbSize = sizeof(clmi);
+
+ CLISTMENUITEM clmi = { sizeof(clmi) };
clmi.flags = CMIM_ICON;
clmi.hIcon = ske_ImageList_GetIcon(hCListImages,NewGroupIconidx,0);
CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)hNewSubGroupMenuItem,(LPARAM)&clmi);
CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)hNewGroupMenuItem,(LPARAM)&clmi);
- //
-
-
return 0;
-};
+}
void GroupMenus_Init(void)
{
@@ -309,13 +304,10 @@ void GroupMenus_Init(void) op.Value = (INT_PTR)"CLISTMENUSGroup/GroupMenuonAddService";
CallService(MO_SETOPTIONSMENUOBJECT,0,(LPARAM)&op);
- {
//add exit command to menu
- CLISTMENUITEM mi;
GroupMenuParam gmp;
- memset(&mi,0,sizeof(mi));
- mi.cbSize = sizeof(mi);
+ CLISTMENUITEM mi = { sizeof(mi) };
mi.position = 1900000;
mi.pszService = "CloseAction";
mi.icolibItem = LoadSkinnedIconHandle(SKINICON_OTHER_EXIT);
@@ -344,7 +336,6 @@ void GroupMenus_Init(void) AddGroupMenuItem(0,(LPARAM)&mi);
DestroyIcon_protect(mi.hIcon);
-
memset(&mi,0,sizeof(mi));
mi.cbSize = sizeof(mi);
mi.position = 300000;
@@ -411,7 +402,6 @@ void GroupMenus_Init(void) mi.pszName = LPGEN("Hide &Offline Users out here");
hHideOfflineUsersOutHereMenuItem = (HANDLE)AddGroupMenuItem(0,(LPARAM)&mi);
-
memset(&mi,0,sizeof(mi));
mi.cbSize = sizeof(mi);
mi.position = 100003;
@@ -420,8 +410,6 @@ void GroupMenus_Init(void) mi.pszName = LPGEN("Hide &Empty Groups");
hHideEmptyGroupsMenuItem = (HANDLE)AddGroupMenuItem(0,(LPARAM)&mi);
-
-
memset(&mi,0,sizeof(mi));
mi.cbSize = sizeof(mi);
mi.position = 100004;
@@ -430,12 +418,7 @@ void GroupMenus_Init(void) mi.pszName = LPGEN("Disable &Groups");
hDisableGroupsMenuItem = (HANDLE)AddGroupMenuItem(0,(LPARAM)&mi);
-
HookEvent(ME_SKIN2_ICONSCHANGED,OnIconLibIconChanged);
-
- //MS_CLIST_GROUPCREATE
-
- };
}
//////////////////////////////END Group MENU/////////////////////////
@@ -470,34 +453,31 @@ static INT_PTR RemoveSubGroupMenuItem(WPARAM wParam,LPARAM lParam) static int OnBuildSubGroupMenu(WPARAM wParam,LPARAM lParam)
{
- CLISTMENUITEM mi;
- BOOL gray1 = FALSE;
- BOOL gray2 = FALSE;
- BOOL showOfflineinGroup = FALSE;
-
-
+ BOOL gray1 = FALSE;
+ BOOL gray2 = FALSE;
+ BOOL showOfflineinGroup = FALSE;
+
ClcGroup *group = (ClcGroup *)wParam;
if (wParam == 0) return 0;
- if (MirandaExiting()) return 0;
+ if (MirandaExiting()) return 0;
//contact->group
- ZeroMemory(&mi,sizeof(mi));
- mi.cbSize = sizeof(mi);
- showOfflineinGroup = CLCItems_IsShowOfflineGroup(group);
- gray1 = (showOfflineinGroup != FALSE);
- gray2 = (group->hideOffline != FALSE);
-
- if (gray1 && gray2) gray1 = FALSE; //should not be cause CLCItems_IsShowOfflineGroup return false if group->hideOffline
-
- mi.flags = CMIM_FLAGS | ((group->hideOffline && !gray1)?CMIF_CHECKED:0)| (gray1?CMIF_GRAYED:0);
+ showOfflineinGroup = CLCItems_IsShowOfflineGroup(group);
+ gray1 = (showOfflineinGroup != FALSE);
+ gray2 = (group->hideOffline != FALSE);
+
+ if (gray1 && gray2) gray1 = FALSE; //should not be cause CLCItems_IsShowOfflineGroup return false if group->hideOffline
+
+ CLISTMENUITEM mi = { sizeof(mi) };
+ mi.flags = CMIM_FLAGS | ((group->hideOffline && !gray1)?CMIF_CHECKED:0)| (gray1?CMIF_GRAYED:0);
CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hHideOfflineUsersHereMenuItem, (LPARAM)&mi);
-
- mi.flags = CMIM_FLAGS | ((showOfflineinGroup && !gray2) ? CMIF_CHECKED:0)| (gray2?CMIF_GRAYED:0);
- CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hShowOfflineUsersHereMenuItem, (LPARAM)&mi);
-
+
+ mi.flags = CMIM_FLAGS | ((showOfflineinGroup && !gray2) ? CMIF_CHECKED:0)| (gray2?CMIF_GRAYED:0);
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hShowOfflineUsersHereMenuItem, (LPARAM)&mi);
return 0;
-};
+}
+
INT_PTR BuildSubGroupMenu(WPARAM wParam,LPARAM lParam)
{
ListParam param = { 0 };
@@ -695,11 +675,9 @@ void InitSubGroupMenus(void) CallService(MO_SETOPTIONSMENUOBJECT,0,(LPARAM)&op);
//add exit command to menu
- CLISTMENUITEM mi;
GroupMenuParam gmp;
- memset(&mi,0,sizeof(mi));
- mi.cbSize = sizeof(mi);
+ CLISTMENUITEM mi = { sizeof(mi) };
mi.position = 1000;
mi.hIcon = ske_ImageList_GetIcon(hCListImages,NewGroupIconidx,0);
mi.pszService = "CLISTMENUSSubGroup/GroupMenuExecProxy";
@@ -708,8 +686,6 @@ void InitSubGroupMenus(void) hNewSubGroupMenuItem = (HANDLE)AddSubGroupMenuItem((WPARAM)&gmp,(LPARAM)&mi);
DestroyIcon_protect(mi.hIcon);
- memset(&mi,0,sizeof(mi));
- mi.cbSize = sizeof(mi);
mi.position = 1001;
mi.hIcon = NULL;
mi.pszService = "CLISTMENUSSubGroup/GroupMenuExecProxy";
@@ -718,8 +694,6 @@ void InitSubGroupMenus(void) gmp.wParam = POPUP_GROUPHIDEOFFLINE;
hHideOfflineUsersHereMenuItem = (HANDLE)AddSubGroupMenuItem((WPARAM)&gmp,(LPARAM)&mi);
- memset(&mi,0,sizeof(mi));
- mi.cbSize = sizeof(mi);
mi.position = 1002;
mi.hIcon = NULL;
mi.pszService = "CLISTMENUSSubGroup/GroupMenuExecProxy";
@@ -739,8 +713,6 @@ void InitSubGroupMenus(void) AddSubGroupMenuItem((WPARAM)&gmp,(LPARAM)&mi);
DestroyIcon_protect(mi.hIcon);
- memset(&mi,0,sizeof(mi));
- mi.cbSize = sizeof(mi);
mi.position = 900002;
mi.flags = CMIF_ICONFROMICOLIB;
mi.icolibItem = LoadSkinnedIconHandle(SKINICON_OTHER_DELETE);
|