From 3c3134cac993e607299b3a9dfc1e02bea811b9df Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 29 May 2021 18:16:14 +0300 Subject: =?UTF-8?q?fixes=20#2893=20(=D0=A1=D0=B5=D0=B9=D1=87=D0=B0=D1=81,?= =?UTF-8?q?=20=D1=87=D1=82=D0=BE=D0=B1=D1=8B=20=D0=B7=D0=B0=D0=BF=D1=83?= =?UTF-8?q?=D1=81=D1=82=D0=B8=D1=82=D1=8C=20=D0=BF=D0=BE=D0=B8=D1=81=D0=BA?= =?UTF-8?q?=20=D0=BF=D0=BE=20=D0=B8=D1=81=D1=82=D0=BE=D1=80=D0=B8=D0=B8,?= =?UTF-8?q?=20=D0=BD=D1=83=D0=B6=D0=BD=D0=BE=20=D0=BD=D0=B0=D0=B6=D0=B0?= =?UTF-8?q?=D1=82=D1=8C=20=D0=BC=D1=8B=D1=88=D0=BA=D0=BE=D0=B9=20=D0=BA?= =?UTF-8?q?=D0=BD=D0=BE=D0=BF=D0=BA=D1=83=20"Find".=20=D0=9D=D0=BE=20?= =?UTF-8?q?=D1=80=D1=83=D0=BA=D0=B0=20=D1=81=D0=B0=D0=BC=D0=B0=20=D1=82?= =?UTF-8?q?=D1=8F=D0=BD=D0=B5=D1=82=D1=81=D1=8F=20=D0=BA=20Ctrl+F)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/stduihist/src/history.cpp | 71 +++++++++++++++++++++----------------- src/core/stduihist/src/stdafx.h | 9 +++-- 2 files changed, 44 insertions(+), 36 deletions(-) (limited to 'src') diff --git a/src/core/stduihist/src/history.cpp b/src/core/stduihist/src/history.cpp index 8d924cf96f..3b0918c393 100644 --- a/src/core/stduihist/src/history.cpp +++ b/src/core/stduihist/src/history.cpp @@ -29,11 +29,31 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define DM_FINDNEXT (WM_USER+10) #define DM_HREBUILD (WM_USER+11) -static INT_PTR CALLBACK DlgProcHistory(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); -static INT_PTR CALLBACK DlgProcHistoryFind(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); static MWindowList hWindowList = nullptr; static HGENMENU hContactMenu = nullptr; +///////////////////////////////////////////////////////////////////////////////////////// +// Find dialog window procedure + +class CHistoryFindDlg : public CDlgBase +{ +public: + CHistoryFindDlg(HWND hwndParent) : + CDlgBase(g_plugin, IDD_HISTORY_FIND) + { + SetParent(hwndParent); + } + + bool OnApply() override + { + wchar_t str[128]; + GetDlgItemText(m_hwnd, IDC_FINDWHAT, str, _countof(str)); + CharUpperW(str); + SendMessage(m_hwndParent, DM_FINDNEXT, 0, (LPARAM)str); + return true; + } +}; + ///////////////////////////////////////////////////////////////////////////////////////// // Fills the events list @@ -141,6 +161,15 @@ static int HistoryDlgResizer(HWND, LPARAM, UTILRESIZECONTROL *urc) return RD_ANCHORX_LEFT | RD_ANCHORY_TOP; } +static LRESULT HotkeyProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + if (msg == WM_CHAR) + if (wParam == 0x06) // Ctrl+F + PostMessage(GetParent(hwndDlg), WM_COMMAND, IDC_FIND, 0); + + return mir_callNextSubclass(hwndDlg, HotkeyProc, msg, wParam, lParam); +} + static INT_PTR CALLBACK DlgProcHistory(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); @@ -159,6 +188,9 @@ static INT_PTR CALLBACK DlgProcHistory(HWND hwndDlg, UINT msg, WPARAM wParam, LP } else SetWindowText(hwndDlg, TranslateT("System history")); + mir_subclassWindow(GetDlgItem(hwndDlg, IDC_LIST), HotkeyProc); + mir_subclassWindow(GetDlgItem(hwndDlg, IDC_EDIT), HotkeyProc); + Window_SetSkinIcon_IcoLib(hwndDlg, SKINICON_OTHER_HISTORY); SendMessage(hwndDlg, DM_HREBUILD, 0, 0); return TRUE; @@ -196,7 +228,7 @@ static INT_PTR CALLBACK DlgProcHistory(HWND hwndDlg, UINT msg, WPARAM wParam, LP return TRUE; case IDC_FIND: - ShowWindow(CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_HISTORY_FIND), hwndDlg, DlgProcHistoryFind, (LPARAM)hwndDlg), SW_SHOW); + (new CHistoryFindDlg(hwndDlg))->Show(); return TRUE; case IDC_DELETEHISTORY: @@ -216,7 +248,11 @@ static INT_PTR CALLBACK DlgProcHistory(HWND hwndDlg, UINT msg, WPARAM wParam, LP case IDC_LIST: if (HIWORD(wParam) == LBN_SELCHANGE) { int sel = SendDlgItemMessage(hwndDlg, IDC_LIST, LB_GETCURSEL, 0, 0); - if (sel == LB_ERR) { EnableWindow(GetDlgItem(hwndDlg, IDC_DELETEHISTORY), FALSE); break; } + if (sel == LB_ERR) { + EnableWindow(GetDlgItem(hwndDlg, IDC_DELETEHISTORY), FALSE); + break; + } + EnableWindow(GetDlgItem(hwndDlg, IDC_DELETEHISTORY), TRUE); MEVENT hDbEvent = SendDlgItemMessage(hwndDlg, IDC_LIST, LB_GETITEMDATA, sel, 0); @@ -279,33 +315,6 @@ static INT_PTR CALLBACK DlgProcHistory(HWND hwndDlg, UINT msg, WPARAM wParam, LP return FALSE; } -static INT_PTR CALLBACK DlgProcHistoryFind(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch (msg) { - case WM_INITDIALOG: - TranslateDialogDefault(hwndDlg); - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam); - return TRUE; - - case WM_COMMAND: - switch (LOWORD(wParam)) { - case IDCANCEL: - DestroyWindow(hwndDlg); - return TRUE; - - case IDOK://find Next - wchar_t str[128]; - HWND hwndParent = (HWND)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - GetDlgItemText(hwndDlg, IDC_FINDWHAT, str, _countof(str)); - CharUpperBuff(str, (int)mir_wstrlen(str)); - SendMessage(hwndParent, DM_FINDNEXT, 0, (LPARAM)str); - return TRUE; - } - break; - } - return FALSE; -} - ///////////////////////////////////////////////////////////////////////////////////////// static INT_PTR UserHistoryCommand(WPARAM wParam, LPARAM) diff --git a/src/core/stduihist/src/stdafx.h b/src/core/stduihist/src/stdafx.h index b95dffe789..1bd6eab031 100644 --- a/src/core/stduihist/src/stdafx.h +++ b/src/core/stduihist/src/stdafx.h @@ -42,13 +42,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include +#include +#include #include -#include +#include #include -#include -#include -#include -#include +#include #include #include #include -- cgit v1.2.3