From b97afa71c6593939d96244cd19053846b9992a61 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 2 Jun 2019 15:58:09 +0300 Subject: Button_SetIcon_IcoLib - a helper to set MButton's icon using an icolib handle --- src/mir_app/src/auth.cpp | 8 ++++---- src/mir_app/src/mir_app.def | 1 + src/mir_app/src/mir_app64.def | 1 + src/mir_app/src/proto_opts.cpp | 10 +++++----- src/mir_app/src/skinicons.cpp | 10 +++++++++- 5 files changed, 20 insertions(+), 10 deletions(-) (limited to 'src/mir_app') diff --git a/src/mir_app/src/auth.cpp b/src/mir_app/src/auth.cpp index d6c76c1bfb..cc7716708a 100644 --- a/src/mir_app/src/auth.cpp +++ b/src/mir_app/src/auth.cpp @@ -54,8 +54,8 @@ public: bool OnInitDialog() override { - Button_SetIcon_IcoLib(m_hwnd, IDC_DETAILS, SKINICON_OTHER_USERDETAILS, LPGEN("View user's details")); - Button_SetIcon_IcoLib(m_hwnd, IDC_ADD, SKINICON_OTHER_ADDCONTACT, LPGEN("Add contact permanently to list")); + Button_SetSkin_IcoLib(m_hwnd, IDC_DETAILS, SKINICON_OTHER_USERDETAILS, LPGEN("View user's details")); + Button_SetSkin_IcoLib(m_hwnd, IDC_ADD, SKINICON_OTHER_ADDCONTACT, LPGEN("Add contact permanently to list")); int iBlobSize = db_event_getBlobSize(m_hDbEvent); if (iBlobSize == -1) @@ -201,8 +201,8 @@ public: bool OnInitDialog() override { - Button_SetIcon_IcoLib(m_hwnd, IDC_DETAILS, SKINICON_OTHER_USERDETAILS, LPGEN("View user's details")); - Button_SetIcon_IcoLib(m_hwnd, IDC_ADD, SKINICON_OTHER_ADDCONTACT, LPGEN("Add contact permanently to list")); + Button_SetSkin_IcoLib(m_hwnd, IDC_DETAILS, SKINICON_OTHER_USERDETAILS, LPGEN("View user's details")); + Button_SetSkin_IcoLib(m_hwnd, IDC_ADD, SKINICON_OTHER_ADDCONTACT, LPGEN("Add contact permanently to list")); // blob is: uin(DWORD), hcontact(HANDLE), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ) DBEVENTINFO dbei = {}; diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index c04d269389..c2b15bb198 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -22,6 +22,7 @@ IcoLib_RemoveIcon @20 IcoLib_RemoveIconByHandle @21 IcoLib_Release @22 IcoLib_AddRef @23 +Button_SetSkin_IcoLib @24 ??0CProtoIntDlgBase@@QAE@ABV0@@Z @25 NONAME ??0CProtoIntDlgBase@@QAE@PAUPROTO_INTERFACE@@H@Z @26 NONAME ??0PROTO_INTERFACE@@QAE@ABU0@@Z @27 NONAME diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index 06c417483d..864376d2ca 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -22,6 +22,7 @@ IcoLib_RemoveIcon @20 IcoLib_RemoveIconByHandle @21 IcoLib_Release @22 IcoLib_AddRef @23 +Button_SetSkin_IcoLib @24 ??0CProtoIntDlgBase@@QEAA@AEBV0@@Z @25 NONAME ??0CProtoIntDlgBase@@QEAA@PEAUPROTO_INTERFACE@@H@Z @26 NONAME ??0PROTO_INTERFACE@@QEAA@AEBU0@@Z @27 NONAME diff --git a/src/mir_app/src/proto_opts.cpp b/src/mir_app/src/proto_opts.cpp index ba38cee3b9..f64dff3ea0 100644 --- a/src/mir_app/src/proto_opts.cpp +++ b/src/mir_app/src/proto_opts.cpp @@ -273,11 +273,11 @@ public: { Window_SetSkinIcon_IcoLib(m_hwnd, SKINICON_OTHER_ACCMGR); - Button_SetIcon_IcoLib(m_hwnd, IDC_ADD, SKINICON_OTHER_ADDCONTACT, LPGEN("New account")); - Button_SetIcon_IcoLib(m_hwnd, IDC_EDIT, SKINICON_OTHER_RENAME, LPGEN("Edit")); - Button_SetIcon_IcoLib(m_hwnd, IDC_REMOVE, SKINICON_OTHER_DELETE, LPGEN("Remove account")); - Button_SetIcon_IcoLib(m_hwnd, IDC_OPTIONS, SKINICON_OTHER_OPTIONS, LPGEN("Configure...")); - Button_SetIcon_IcoLib(m_hwnd, IDC_UPGRADE, SKINICON_OTHER_ACCMGR, LPGEN("Upgrade account")); + Button_SetSkin_IcoLib(m_hwnd, IDC_ADD, SKINICON_OTHER_ADDCONTACT, LPGEN("New account")); + Button_SetSkin_IcoLib(m_hwnd, IDC_EDIT, SKINICON_OTHER_RENAME, LPGEN("Edit")); + Button_SetSkin_IcoLib(m_hwnd, IDC_REMOVE, SKINICON_OTHER_DELETE, LPGEN("Remove account")); + Button_SetSkin_IcoLib(m_hwnd, IDC_OPTIONS, SKINICON_OTHER_OPTIONS, LPGEN("Configure...")); + Button_SetSkin_IcoLib(m_hwnd, IDC_UPGRADE, SKINICON_OTHER_ACCMGR, LPGEN("Upgrade account")); m_btnEdit.Disable(); m_btnRemove.Disable(); diff --git a/src/mir_app/src/skinicons.cpp b/src/mir_app/src/skinicons.cpp index f583de9562..73e4e6fb7e 100644 --- a/src/mir_app/src/skinicons.cpp +++ b/src/mir_app/src/skinicons.cpp @@ -203,7 +203,7 @@ MIR_APP_DLL(void) Window_FreeIcon_IcoLib(HWND hWnd) IcoLib_ReleaseIcon((HICON)SendMessage(hWnd, WM_SETICON, ICON_SMALL, 0), false); } -MIR_APP_DLL(void) Button_SetIcon_IcoLib(HWND hwndDlg, int itemId, int iconId, const char *tooltip) +MIR_APP_DLL(void) Button_SetSkin_IcoLib(HWND hwndDlg, int itemId, int iconId, const char *tooltip) { HWND hWnd = GetDlgItem(hwndDlg, itemId); SendMessage(hWnd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Skin_LoadIcon(iconId, false)); @@ -211,6 +211,14 @@ MIR_APP_DLL(void) Button_SetIcon_IcoLib(HWND hwndDlg, int itemId, int iconId, co SendMessage(hWnd, BUTTONADDTOOLTIP, (WPARAM)tooltip, 0); } +MIR_APP_DLL(void) Button_SetIcon_IcoLib(HWND hwndDlg, int itemId, HANDLE hIcolib, const char *tooltip) +{ + HWND hWnd = GetDlgItem(hwndDlg, itemId); + SendMessage(hWnd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIconByHandle(hIcolib, false)); + SendMessage(hWnd, BUTTONSETASFLATBTN, TRUE, 0); + SendMessage(hWnd, BUTTONADDTOOLTIP, (WPARAM)tooltip, 0); +} + MIR_APP_DLL(void) Button_FreeIcon_IcoLib(HWND hwndDlg, int itemId) { HICON hIcon = (HICON)SendDlgItemMessage(hwndDlg, itemId, BM_SETIMAGE, IMAGE_ICON, 0); -- cgit v1.2.3