diff options
author | George Hazan <ghazan@miranda.im> | 2016-12-10 15:50:53 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2016-12-10 15:50:53 +0300 |
commit | 5fea43e9b07b966fe023105bfd9a224bfbb00e7b (patch) | |
tree | 5868406c223c0ed4cca707f258dc55c331844298 /src/mir_app | |
parent | 271558cf6114d70da75ed474d7c04fa707ae3369 (diff) |
- ability to pass a button's text to a toolbar button;
- common code moved into the core
Diffstat (limited to 'src/mir_app')
-rw-r--r-- | src/mir_app/src/mir_app.def | 1 | ||||
-rw-r--r-- | src/mir_app/src/mir_app64.def | 1 | ||||
-rw-r--r-- | src/mir_app/src/srmm_toolbar.cpp | 30 |
3 files changed, 32 insertions, 0 deletions
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index da19c3658d..7ad0d3650d 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -344,3 +344,4 @@ Miranda_OkToExit @344 Miranda_GetVersion @345
Miranda_GetFileVersion @346
Miranda_GetVersionText @347
+Srmm_CreateToolbarIcons @348
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index 84a99f806f..68a6b11090 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -344,3 +344,4 @@ Miranda_OkToExit @344 Miranda_GetVersion @345
Miranda_GetFileVersion @346
Miranda_GetVersionText @347
+Srmm_CreateToolbarIcons @348
diff --git a/src/mir_app/src/srmm_toolbar.cpp b/src/mir_app/src/srmm_toolbar.cpp index 988f5d9949..88f79dc544 100644 --- a/src/mir_app/src/srmm_toolbar.cpp +++ b/src/mir_app/src/srmm_toolbar.cpp @@ -119,6 +119,7 @@ MIR_APP_DLL(int) Srmm_AddButton(const BBButton *bbdi, int _hLang) cbd->m_iButtonWidth = DPISCALEX_S(22); cbd->m_pszModuleName = mir_strdup(bbdi->pszModuleName); + cbd->m_pwszText = mir_wstrdup(bbdi->pwszText); cbd->m_pwszTooltip = mir_wstrdup(bbdi->pwszTooltip); cbd->m_dwButtonOrigID = bbdi->dwButtonID; @@ -314,6 +315,35 @@ MIR_APP_DLL(void) Srmm_ResetToolbar() dwSepCount = 0; } +MIR_APP_DLL(void) Srmm_CreateToolbarIcons(HWND hwndDlg, int flags) +{ + HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtr(hwndDlg, GWLP_HINSTANCE); + + for (int i = 0; i < arButtonsList.getCount(); i++) { + CustomButtonData *cbd = arButtonsList[i]; + if (cbd->m_bSeparator) + continue; + + HWND hwndButton = GetDlgItem(hwndDlg, cbd->m_dwButtonCID); + if ((flags & BBBF_ISIMBUTTON) && cbd->m_bIMButton || (flags & BBBF_ISCHATBUTTON) && cbd->m_bChatButton) { + if (hwndButton == NULL) { + hwndButton = CreateWindowEx(0, L"MButtonClass", L"", WS_CHILD | WS_VISIBLE | WS_TABSTOP, 0, 0, cbd->m_iButtonWidth, 22, hwndDlg, (HMENU)cbd->m_dwButtonCID, hInstance, NULL); + if (hwndButton == NULL) // smth went wrong + continue; + } + SendMessage(hwndButton, BUTTONSETASFLATBTN, TRUE, 0); + if (cbd->m_pwszText) + SetWindowTextW(hwndButton, cbd->m_pwszText); + if (cbd->m_pwszTooltip) + SendMessage(hwndButton, BUTTONADDTOOLTIP, LPARAM(cbd->m_pwszTooltip), BATF_UNICODE); + if (cbd->m_hIcon) + SendMessage(hwndButton, BM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIconByHandle(cbd->m_hIcon)); + } + else if (hwndButton) + DestroyWindow(hwndButton); + } +} + MIR_APP_DLL(void) Srmm_UpdateToolbarIcons(HWND hwndDlg) { for (int i = 0; i < arButtonsList.getCount(); i++) { |