summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2021-05-29 18:16:14 +0300
committerGeorge Hazan <ghazan@miranda.im>2021-05-29 18:16:14 +0300
commit3c3134cac993e607299b3a9dfc1e02bea811b9df (patch)
tree27f5f61c74d0b27fdcfc2f2471e0ebf25ccbc47c /src
parent1781b1895c583f7d5767e2376681695c7a618083 (diff)
fixes #2893 (Сейчас, чтобы запустить поиск по истории, нужно нажать мышкой кнопку "Find". Но рука сама тянется к Ctrl+F)
Diffstat (limited to 'src')
-rw-r--r--src/core/stduihist/src/history.cpp71
-rw-r--r--src/core/stduihist/src/stdafx.h9
2 files changed, 44 insertions, 36 deletions
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,12 +29,32 @@ 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
static void GetObjectSummary(DBEVENTINFO *dbei, wchar_t *str, int cbStr)
@@ -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 <m_system.h>
#include <newpluginapi.h>
+#include <m_button.h>
+#include <m_clist.h>
#include <m_database.h>
-#include <m_netlib.h>
+#include <m_gui.h>
#include <m_langpack.h>
-#include <m_clist.h>
-#include <m_button.h>
-#include <m_protosvc.h>
-#include <m_protocols.h>
+#include <m_netlib.h>
#include <m_options.h>
#include <m_skin.h>
#include <m_contacts.h>