From eec361608fde60d63fe4511e26e3b95c7f72be13 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 5 Jun 2016 16:11:08 +0000 Subject: - fix for #1059; - direct unsafe work with icons replaces with Window_SetIcon_IcoLib / Window_SetSkinIcon_IcoLib; - code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@16917 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Gadu-Gadu/src/gg.h | 2 -- protocols/Gadu-Gadu/src/groupchat.cpp | 7 ++++--- protocols/Gadu-Gadu/src/icolib.cpp | 12 ------------ protocols/Gadu-Gadu/src/image.cpp | 6 +++--- protocols/Gadu-Gadu/src/sessions.cpp | 4 ++-- protocols/Gadu-Gadu/src/userutils.cpp | 4 ++-- 6 files changed, 11 insertions(+), 24 deletions(-) (limited to 'protocols/Gadu-Gadu/src') diff --git a/protocols/Gadu-Gadu/src/gg.h b/protocols/Gadu-Gadu/src/gg.h index 7a8d0978e2..a06ed4dfb2 100644 --- a/protocols/Gadu-Gadu/src/gg.h +++ b/protocols/Gadu-Gadu/src/gg.h @@ -322,8 +322,6 @@ void gg_icolib_init(); HICON LoadIconEx(const char* name, bool big); HANDLE GetIconHandle(int iconId); void ReleaseIconEx(const char* name, bool big); -void WindowSetIcon(HWND hWnd, const char* name); -void WindowFreeIcon(HWND hWnd); /* URI parser functions */ void gg_links_instancemenu_init(); diff --git a/protocols/Gadu-Gadu/src/groupchat.cpp b/protocols/Gadu-Gadu/src/groupchat.cpp index ba8ad0b620..305e398548 100644 --- a/protocols/Gadu-Gadu/src/groupchat.cpp +++ b/protocols/Gadu-Gadu/src/groupchat.cpp @@ -442,7 +442,7 @@ static INT_PTR CALLBACK gg_gc_openconfdlg(HWND hwndDlg, UINT message, WPARAM wPa SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)lParam); TranslateDialogDefault(hwndDlg); - WindowSetIcon(hwndDlg, "conference"); + Window_SetIcon_IcoLib(hwndDlg, GetIconHandle(IDI_CONFERENCE)); gg_gc_resetclistopts(GetDlgItem(hwndDlg, IDC_CLIST)); // Hook MetaContacts event (if available) @@ -567,8 +567,9 @@ static INT_PTR CALLBACK gg_gc_openconfdlg(HWND hwndDlg, UINT message, WPARAM wPa case WM_DESTROY: { HANDLE hMetaContactsEvent = (HANDLE)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - if (hMetaContactsEvent) UnhookEvent(hMetaContactsEvent); - WindowFreeIcon(hwndDlg); + if (hMetaContactsEvent) + UnhookEvent(hMetaContactsEvent); + Window_FreeIcon_IcoLib(hwndDlg); break; } } diff --git a/protocols/Gadu-Gadu/src/icolib.cpp b/protocols/Gadu-Gadu/src/icolib.cpp index ea6e2503a2..0a81610891 100644 --- a/protocols/Gadu-Gadu/src/icolib.cpp +++ b/protocols/Gadu-Gadu/src/icolib.cpp @@ -69,15 +69,3 @@ void ReleaseIconEx(const char* name, bool big) mir_snprintf(szSettingName, "%s_%s", GGDEF_PROTO, name); IcoLib_Release(szSettingName, big); } - -void WindowSetIcon(HWND hWnd, const char* name) -{ - SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM)LoadIconEx(name, TRUE)); - SendMessage(hWnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadIconEx(name, FALSE)); -} - -void WindowFreeIcon(HWND hWnd) -{ - IcoLib_ReleaseIcon((HICON)SendMessage(hWnd, WM_SETICON, ICON_BIG, 0)); - IcoLib_ReleaseIcon((HICON)SendMessage(hWnd, WM_SETICON, ICON_SMALL, 0)); -} diff --git a/protocols/Gadu-Gadu/src/image.cpp b/protocols/Gadu-Gadu/src/image.cpp index 2f9d849c7e..87ccaa2a54 100644 --- a/protocols/Gadu-Gadu/src/image.cpp +++ b/protocols/Gadu-Gadu/src/image.cpp @@ -416,8 +416,8 @@ static INT_PTR CALLBACK gg_img_dlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LP SendDlgItemMessage(hwndDlg, IDC_IMG_SAVE, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Save image to disk"), BATF_TCHAR); // Set main window image - WindowSetIcon(hwndDlg, "image"); - + Window_SetIcon_IcoLib(hwndDlg, GetIconHandle(IDI_IMAGE)); + TCHAR *szName = pcli->pfnGetContactDisplayName(dat->hContact, 0), szTitle[128]; if (dat->bReceiving) mir_sntprintf(szTitle, TranslateT("Image from %s"), szName); @@ -519,7 +519,7 @@ static INT_PTR CALLBACK gg_img_dlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LP ReleaseIconEx("next", FALSE); ReleaseIconEx("delete", FALSE); ReleaseIconEx("save", FALSE); - WindowFreeIcon(hwndDlg); + Window_FreeIcon_IcoLib(hwndDlg); gg->gg_EnterCriticalSection(&gg->img_mutex, "gg_img_dlgproc", 58, "img_mutex", 1); list_remove(&gg->imagedlgs, dat, 1); gg->gg_LeaveCriticalSection(&gg->img_mutex, "gg_img_dlgproc", 58, 1, "img_mutex", 1); diff --git a/protocols/Gadu-Gadu/src/sessions.cpp b/protocols/Gadu-Gadu/src/sessions.cpp index 6ef0fafce7..ba881c9d3a 100644 --- a/protocols/Gadu-Gadu/src/sessions.cpp +++ b/protocols/Gadu-Gadu/src/sessions.cpp @@ -170,7 +170,7 @@ static INT_PTR CALLBACK gg_sessions_viewdlg(HWND hwndDlg, UINT message, WPARAM w GetWindowText(hwndDlg, oldTitle, _countof(oldTitle)); mir_sntprintf(newTitle, oldTitle, gg->m_tszUserName); SetWindowText(hwndDlg, newTitle); - WindowSetIcon(hwndDlg, "sessions"); + Window_SetIcon_IcoLib(hwndDlg, GetIconHandle(IDI_SESSIONS)); if (hHandCursor == NULL) hHandCursor = LoadCursor(NULL, IDC_HAND); @@ -383,7 +383,7 @@ static INT_PTR CALLBACK gg_sessions_viewdlg(HWND hwndDlg, UINT message, WPARAM w HANDLE hProtoAckEvent = (HANDLE)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); if (hProtoAckEvent) UnhookEvent(hProtoAckEvent); gg->hwndSessionsDlg = NULL; - WindowFreeIcon(hwndDlg); + Window_FreeIcon_IcoLib(hwndDlg); break; } } diff --git a/protocols/Gadu-Gadu/src/userutils.cpp b/protocols/Gadu-Gadu/src/userutils.cpp index e513112247..90cc89579a 100644 --- a/protocols/Gadu-Gadu/src/userutils.cpp +++ b/protocols/Gadu-Gadu/src/userutils.cpp @@ -211,7 +211,7 @@ INT_PTR CALLBACK gg_userutildlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); - WindowSetIcon(hwndDlg, "settings"); + Window_SetIcon_IcoLib(hwndDlg, GetIconHandle(IDI_SETTINGS)); dat = (GGUSERUTILDLGDATA *)lParam; SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam); if (dat) SetDlgItemTextA(hwndDlg, IDC_EMAIL, dat->email); // Readup email @@ -271,7 +271,7 @@ INT_PTR CALLBACK gg_userutildlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA break; case WM_DESTROY: - WindowFreeIcon(hwndDlg); + Window_FreeIcon_IcoLib(hwndDlg); break; } return FALSE; -- cgit v1.2.3