diff options
author | George Hazan <george.hazan@gmail.com> | 2012-12-01 13:25:11 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-12-01 13:25:11 +0000 |
commit | 854959cbc0a1bad2c086214be4d1a829b17a61f3 (patch) | |
tree | ee3de50f4b4e57f54ae20d139f97fa469ff90d34 /plugins/Sessions | |
parent | 73ddc73d92675399e4619758d4b0881418de0a6d (diff) |
icolib: icon creation quirks
git-svn-id: http://svn.miranda-ng.org/main/trunk@2588 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Sessions')
-rw-r--r-- | plugins/Sessions/Src/Main.cpp | 85 | ||||
-rw-r--r-- | plugins/Sessions/Src/Utils.cpp | 17 | ||||
-rw-r--r-- | plugins/Sessions/Src/Utils.h | 2 |
3 files changed, 45 insertions, 59 deletions
diff --git a/plugins/Sessions/Src/Main.cpp b/plugins/Sessions/Src/Main.cpp index ac82ba2010..31d5bdddac 100644 --- a/plugins/Sessions/Src/Main.cpp +++ b/plugins/Sessions/Src/Main.cpp @@ -23,12 +23,10 @@ HINSTANCE hinstance = NULL; WNDPROC mainProc;
-HANDLE hServiceOpenManager,hServiceShowFavMenu,hServiceCloseCurrentSession,hServiceSaveUserSession,
-hServiceLoadLastSession,hmSaveCurrentSession, hmLoadLastSession,hmLoadSession,hmSessionsManager,
-hibSessionsLoad,hibSessionsSave,hibSessionsLoadLast,hibChecked,hibNotChecked;
-
-HICON hiChecked,hiNotChecked,hiSessions,hiSessionsLoad ,hiSessionsSave,hiSessionsLoadLast;
-
+HANDLE
+ hServiceOpenManager, hServiceShowFavMenu, hServiceCloseCurrentSession, hServiceSaveUserSession,
+ hServiceLoadLastSession, hmSaveCurrentSession, hmLoadLastSession, hmLoadSession, hmSessionsManager,
+ hibSessions, hibSessionsLoad, hibSessionsSave, hibSessionsLoadLast, hibChecked, hibNotChecked;
HANDLE hmTBButton[2],hiTBbutton[2],iTBbutton[2];
@@ -781,18 +779,9 @@ int SessionPreShutdown(WPARAM wparam,LPARAM lparam) if (g_hDlg) DestroyWindow(g_hDlg);
if (g_hSDlg) DestroyWindow(g_hSDlg);
- DestroyIcon(hiSessions);
- DestroyIcon(hiSessionsLoad);
- DestroyIcon(hiSessionsSave);
- DestroyIcon(hiSessionsLoadLast);
- DestroyIcon(hiChecked);
- DestroyIcon(hiNotChecked);
-
- if(g_bIncompletedSave)
- {
+ if(g_bIncompletedSave) {
int i=0;
- while(session_list_recovered[i])
- {
+ while(session_list_recovered[i]) {
DBWriteContactSettingByte((HANDLE)session_list_recovered[i], __INTERNAL_NAME, "wasInLastSession", 0);
i++;
}
@@ -888,21 +877,20 @@ static int PluginInit(WPARAM wparam,LPARAM lparam) HookEvent(ME_OPT_INITIALISE, OptionsInit);
HookEvent(ME_TTB_MODULELOADED, CreateButtons);
- hServiceShowFavMenu=CreateServiceFunction(MS_SESSIONS_SHOWFAVORITESMENU, BuildFavMenu);
- hServiceOpenManager=CreateServiceFunction(MS_SESSIONS_OPENMANAGER, OpenSessionsManagerWindow);
- hServiceLoadLastSession=CreateServiceFunction(MS_SESSIONS_RESTORELASTSESSION, LoadLastSession/*LoadSession*/);
- hServiceSaveUserSession=CreateServiceFunction(MS_SESSIONS_SAVEUSERSESSION, SaveUserSessionHandles);
- hServiceCloseCurrentSession=CreateServiceFunction(MS_SESSIONS_CLOSESESSION, CloseCurrentSession);
+ hServiceShowFavMenu = CreateServiceFunction(MS_SESSIONS_SHOWFAVORITESMENU, BuildFavMenu);
+ hServiceOpenManager = CreateServiceFunction(MS_SESSIONS_OPENMANAGER, OpenSessionsManagerWindow);
+ hServiceLoadLastSession = CreateServiceFunction(MS_SESSIONS_RESTORELASTSESSION, LoadLastSession/*LoadSession*/);
+ hServiceSaveUserSession = CreateServiceFunction(MS_SESSIONS_SAVEUSERSESSION, SaveUserSessionHandles);
+ hServiceCloseCurrentSession = CreateServiceFunction(MS_SESSIONS_CLOSESESSION, CloseCurrentSession);
- g_ses_count=DBGetContactSettingByte(0, __INTERNAL_NAME, "UserSessionsCount", 0);
+ g_ses_count = DBGetContactSettingByte(0, __INTERNAL_NAME, "UserSessionsCount", 0);
if (!g_ses_count)
- g_ses_count=DBGetContactSettingByte(0, "Sessions (Unicode)", "UserSessionsCount", 0);
- ses_limit=DBGetContactSettingByte(0, __INTERNAL_NAME, "TrackCount", 10);
- g_bExclHidden=DBGetContactSettingByte(NULL, __INTERNAL_NAME, "ExclHidden", 0);
- g_bWarnOnHidden=DBGetContactSettingByte(NULL, __INTERNAL_NAME, "WarnOnHidden", 0);
- g_bOtherWarnings=DBGetContactSettingByte(NULL, __INTERNAL_NAME, "OtherWarnings", 1);
- g_bCrashRecovery=DBGetContactSettingByte(NULL, __INTERNAL_NAME, "CrashRecovery", 0);
-
+ g_ses_count = DBGetContactSettingByte(0, "Sessions (Unicode)", "UserSessionsCount", 0);
+ ses_limit = DBGetContactSettingByte(0, __INTERNAL_NAME, "TrackCount", 10);
+ g_bExclHidden = DBGetContactSettingByte(NULL, __INTERNAL_NAME, "ExclHidden", 0);
+ g_bWarnOnHidden = DBGetContactSettingByte(NULL, __INTERNAL_NAME, "WarnOnHidden", 0);
+ g_bOtherWarnings = DBGetContactSettingByte(NULL, __INTERNAL_NAME, "OtherWarnings", 1);
+ g_bCrashRecovery = DBGetContactSettingByte(NULL, __INTERNAL_NAME, "CrashRecovery", 0);
if(g_bCrashRecovery)
g_bIncompletedSave=!DBGetContactSettingByte(NULL, __INTERNAL_NAME, "lastSaveCompleted", 0);
@@ -938,8 +926,8 @@ static int PluginInit(WPARAM wparam,LPARAM lparam) g_hDlg=CreateDialog(hinstance,MAKEINTRESOURCE(IDD_WLCMDIALOG), 0, LoadSessionDlgProc);
}
- HOTKEYDESC hkd = {0};
- hkd.cbSize = sizeof(hkd);
+ // Hotkeys
+ HOTKEYDESC hkd = { sizeof(hkd) };
hkd.dwFlags = HKD_TCHAR;
hkd.ptszSection = _T("Sessions");
hkd.pszName = "OpenSessionsManager";
@@ -962,50 +950,45 @@ static int PluginInit(WPARAM wparam,LPARAM lparam) hkd.pszService = MS_SESSIONS_CLOSESESSION;
Hotkey_Register(&hkd);
- hiChecked = LoadIcon(hinstance, MAKEINTRESOURCE(IDD_SESSION_CHECKED));
- hiNotChecked = LoadIcon(hinstance, MAKEINTRESOURCE(IDD_SESSION_UNCHECKED));
-
- hiSessions = LoadIcon(hinstance, MAKEINTRESOURCE(IDI_SESSIONS));
- hiSessionsLoad = LoadIcon(hinstance, MAKEINTRESOURCE(IDI_SESSIONS_LOAD));
- hiSessionsSave = LoadIcon(hinstance, MAKEINTRESOURCE(IDD_SESSIONS_SAVE));
- hiSessionsLoadLast = LoadIcon(hinstance, MAKEINTRESOURCE(IDD_SESSIONS_LOADLAST));
-
- hibChecked = AddIcon(hiChecked, "SessionMarked", LPGENT("Favorite Session"));
- hibNotChecked = AddIcon(hiNotChecked, "SessionUnMarked", LPGENT("Not favorite Session"));
- hibSessionsLoad = AddIcon(hiSessionsLoad, "SessionsLoad", LPGENT("Load Session"));
- hibSessionsSave = AddIcon(hiSessionsSave, "SessionsSave", LPGENT("Save Session"));
- hibSessionsLoadLast = AddIcon(hiSessionsLoadLast, "SessionsLoadLast", LPGENT("Load last Session"));
+ // Icons
+ hibSessions = AddIcon("Sessions", LPGEN("Sessions"), IDD_SESSION_CHECKED);
+ hibChecked = AddIcon("SessionMarked", LPGEN("Favorite Session"), IDD_SESSION_CHECKED);
+ hibNotChecked = AddIcon("SessionUnMarked", LPGEN("Not favorite Session"), IDD_SESSION_UNCHECKED);
+ hibSessionsLoad = AddIcon("SessionsLoad", LPGEN("Load Session"), IDI_SESSIONS_LOAD);
+ hibSessionsSave = AddIcon("SessionsSave", LPGEN("Save Session"), IDD_SESSIONS_SAVE);
+ hibSessionsLoadLast = AddIcon("SessionsLoadLast", LPGEN("Load last Session"), IDD_SESSIONS_LOADLAST);
+ // Main menu
CLISTMENUITEM cl = { sizeof(cl) };
cl.position = 1000000000;
- cl.flags = CMIM_ALL | CMIF_TCHAR;
+ cl.flags = CMIM_ALL | CMIF_TCHAR | CMIF_ICONFROMICOLIB;
cl.ptszName = _T("Save session...");
cl.ptszPopupName = _T("Sessions Manager");
- cl.hIcon = hiSessions;
+ cl.icolibItem = hibSessions;
cl.pszService = MS_SESSIONS_SAVEUSERSESSION;
hmSaveCurrentSession = Menu_AddMainMenuItem(&cl);
cl.ptszName = _T("Load session...");
cl.pszService = MS_SESSIONS_OPENMANAGER;
- cl.hIcon = hiSessionsLoad;
+ cl.icolibItem = hibSessionsLoad;
hmLoadLastSession = Menu_AddMainMenuItem(&cl);
cl.ptszName = _T("Close session");
cl.pszService = MS_SESSIONS_CLOSESESSION;
- cl.hIcon = 0;
+ cl.icolibItem = 0;
hmLoadSession = Menu_AddMainMenuItem(&cl);
cl.ptszName = _T("Load last session");
cl.pszService = MS_SESSIONS_RESTORELASTSESSION;
- cl.hIcon = hiSessionsLoadLast;
+ cl.icolibItem = hibSessionsLoadLast;
cl.position = 10100000;
hmLoadSession = Menu_AddMainMenuItem(&cl);
ZeroMemory(&cl, sizeof(cl));
cl.cbSize = sizeof(cl);
cl.flags = CMIM_ICON;
- cl.hIcon = hiSessionsSave;
+ cl.icolibItem = hibSessionsSave;
CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hmSaveCurrentSession, (LPARAM)&cl);
return 0;
diff --git a/plugins/Sessions/Src/Utils.cpp b/plugins/Sessions/Src/Utils.cpp index 93e7849c2c..97c1d7dc95 100644 --- a/plugins/Sessions/Src/Utils.cpp +++ b/plugins/Sessions/Src/Utils.cpp @@ -526,16 +526,19 @@ BYTE IsMarkedUserDefSession(int ses_count) return DBGetContactSettingByte(NULL, __INTERNAL_NAME, szSessionName, 0);
}
-HANDLE AddIcon(HICON icon, char *name, TCHAR *description)
+HANDLE AddIcon(char *name, char *description, int idx)
{
- SKINICONDESC sid = {0};
- sid.cbSize = sizeof(SKINICONDESC);
- sid.flags = SIDF_ALL_TCHAR;
- sid.ptszSection = _T(__INTERNAL_NAME);
+ TCHAR tszPath[MAX_PATH];
+ GetModuleFileName(hinstance, tszPath, SIZEOF(tszPath));
+
+ SKINICONDESC sid = { sizeof(sid) };
+ sid.flags = SIDF_PATH_TCHAR;
+ sid.pszSection = __INTERNAL_NAME;
sid.cx = sid.cy = 16;
- sid.ptszDescription = description;
+ sid.pszDescription = description;
sid.pszName = name;
- sid.hDefaultIcon = icon;
+ sid.ptszDefaultFile = tszPath;
+ sid.iDefaultIndex = -idx;
return Skin_AddIcon( &sid);
}
diff --git a/plugins/Sessions/Src/Utils.h b/plugins/Sessions/Src/Utils.h index f73dad00ad..3e044a4d17 100644 --- a/plugins/Sessions/Src/Utils.h +++ b/plugins/Sessions/Src/Utils.h @@ -33,7 +33,7 @@ int CheckForDuplicate(DWORD contact_list[],DWORD lparam); BOOL ResaveSettings(char* szName,int iFirst,int iLimit,TCHAR* pszPrevSetting);
void OffsetWindow(HWND parent, HWND hwnd, int dx, int dy);
int LoadSessionToCombobox (HWND hdlg,BOOL mode,int iLimit,char* pszSetting,int iFirstNum);
-HANDLE AddIcon(HICON icon, char *name, TCHAR *description);
+HANDLE AddIcon(char *name, char *description, int idx);
int MarkUserDefSession(int ses_count,BYTE bCheck);
BYTE IsMarkedUserDefSession(int ses_count);
void SavePosition(HWND hWnd, char *wndName);
|