From 59651e97603936fc7179864506caa1818e260c76 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 13 May 2013 14:38:12 +0000 Subject: icon registration git-svn-id: http://svn.miranda-ng.org/main/trunk@4643 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/ProfileManager/src/pmanagerEx.cpp | 82 ++++++++++++++----------------- 1 file changed, 36 insertions(+), 46 deletions(-) (limited to 'plugins/ProfileManager') diff --git a/plugins/ProfileManager/src/pmanagerEx.cpp b/plugins/ProfileManager/src/pmanagerEx.cpp index 0c186ba40e..666e74163c 100644 --- a/plugins/ProfileManager/src/pmanagerEx.cpp +++ b/plugins/ProfileManager/src/pmanagerEx.cpp @@ -9,11 +9,12 @@ There is no warranty. #include "Common.h" -HINSTANCE hInst; +#define SRV_LOAD_PM "Database/LoadPM" +#define SRV_CHANGE_PM "Database/ChangePM" +#define SRV_CHECK_DB "Database/CheckDb" +#define SRV_RESTART_ME "System/RestartMe" -TCHAR fn[MAX_PATH]; -TCHAR lmn[MAX_PATH]; -TCHAR* pathn; +HINSTANCE hInst; int hLangpack; PLUGININFOEX pluginInfo={ @@ -35,14 +36,19 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD miranda return &pluginInfo; } +///////////////////////////////////////////////////////////////////////////////////////// + BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { hInst = hinstDLL; return TRUE; } +///////////////////////////////////////////////////////////////////////////////////////// + static INT_PTR ChangePM(WPARAM wParam, LPARAM lParam) { + TCHAR fn[MAX_PATH]; GetModuleFileName(GetModuleHandle(NULL), fn, SIZEOF(fn)); ShellExecute(0, _T("open"), fn, _T("/ForceShowPM"), _T(""), 1); CallService("CloseAction", 0, 0); @@ -51,6 +57,7 @@ static INT_PTR ChangePM(WPARAM wParam, LPARAM lParam) static INT_PTR LoadPM(WPARAM wParam, LPARAM lParam) { + TCHAR fn[MAX_PATH]; GetModuleFileName(GetModuleHandle(NULL), fn, SIZEOF(fn)); ShellExecute(0, _T("open"), fn, _T("/ForceShowPM"), _T(""), 1); return 0; @@ -77,56 +84,39 @@ static INT_PTR RestartMe(WPARAM wParam, LPARAM lParam) return 0; } +static IconItem iconList[] = +{ + { LPGEN("Load profile"), SRV_LOAD_PM, IDI_LoadPM }, + { LPGEN("Change profile"), SRV_CHANGE_PM, IDI_ChangePM }, + { LPGEN("Check database"), SRV_CHECK_DB, IDI_Dbchecker }, + { LPGEN("Restart"), SRV_RESTART_ME, IDI_Restart } +}; + extern "C" __declspec(dllexport) int Load(void) { mir_getLP(&pluginInfo); - CreateServiceFunction("Database/LoadPM", LoadPM); + Icon_Register(hInst, LPGEN("Profile manager"), iconList, SIZEOF(iconList)); + + CreateServiceFunction(SRV_LOAD_PM, LoadPM); + CreateServiceFunction(SRV_CHECK_DB, CheckDb); + CreateServiceFunction(SRV_CHANGE_PM, ChangePM); + CreateServiceFunction(SRV_RESTART_ME, RestartMe); - // !!!!!!!! check it later CLISTMENUITEM mi = { sizeof(mi) }; mi.position = -500200000; - mi.flags = CMIF_TCHAR; - mi.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_LoadPM)); - mi.ptszPopupName = LPGENT("Database"); - mi.ptszName = LPGENT("Load profile"); - mi.pszService = "Database/LoadPM"; - Menu_AddMainMenuItem(&mi); - - CreateServiceFunction("Database/ChangePM", ChangePM); - ZeroMemory(&mi, sizeof(mi)); - mi.cbSize = sizeof(mi); - mi.position = -500200000; - mi.flags = CMIF_TCHAR; - mi.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_ChangePM)); - mi.ptszPopupName = LPGENT("Database"); - mi.ptszName = LPGENT("Change profile"); - mi.pszService = "Database/ChangePM"; - Menu_AddMainMenuItem(&mi); - - CreateServiceFunction("Database/CheckDb", CheckDb); - ZeroMemory(&mi, sizeof(mi)); - mi.cbSize = sizeof(mi); - mi.position = -500200000; - mi.flags = CMIF_TCHAR; - mi.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_Dbchecker)); - mi.ptszPopupName = LPGENT("Database"); - mi.ptszName = LPGENT("Check database"); - mi.pszService = "Database/CheckDb"; - Menu_AddMainMenuItem(&mi); - - CreateServiceFunction("System/RestartMe", RestartMe); - ZeroMemory(&mi, sizeof(mi)); - mi.cbSize = sizeof(mi); - mi.position = -500200000; - mi.flags = CMIF_TCHAR; - mi.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_Restart)); - mi.ptszPopupName = NULL; - mi.ptszName = LPGENT("Restart"); - mi.pszService = "System/RestartMe"; - Menu_AddMainMenuItem(&mi); - Menu_AddTrayMenuItem(&mi); + mi.pszPopupName = LPGEN("Database"); + + for (int i=0; i < SIZEOF(iconList); i++) { + mi.pszName = iconList[i].szDescr; + mi.pszService = iconList[i].szName; + mi.icolibItem = iconList[i].hIcolib; + if (i == 3) + mi.pszPopupName = NULL; + Menu_AddMainMenuItem(&mi); + } + Menu_AddTrayMenuItem(&mi); return 0; } -- cgit v1.2.3