From 16aea17483a38f0348d51862809ad4648168e4f8 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 29 Apr 2021 21:55:35 +0300 Subject: =?UTF-8?q?fixes=20#2866=20(DbEditor:=20=D0=B2=D1=8B=D0=B4=D0=B5?= =?UTF-8?q?=D0=BB=D0=B8=D0=B2=20=D0=BD=D0=B0=D0=B9=D0=B4=D0=B5=D0=BD=D0=BD?= =?UTF-8?q?=D1=8B=D0=B9=20=D0=BF=D0=BE=D0=B8=D1=81=D0=BA=D0=BE=D0=BC=20?= =?UTF-8?q?=D1=8D=D0=BB=D0=B5=D0=BC=D0=B5=D0=BD=D1=82,=20=D0=BD=D0=B5?= =?UTF-8?q?=D0=B2=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD=D0=BE=20=D0=BE=D1=82?= =?UTF-8?q?=D0=BA=D1=80=D1=8B=D1=82=D1=8C=20=D0=B5=D0=B3=D0=BE=20=D0=B2=20?= =?UTF-8?q?=D1=80=D0=B5=D0=B4=D0=B0=D0=BA=D1=82=D0=BE=D1=80=D0=B5=20=D1=81?= =?UTF-8?q?=20=D0=BA=D0=BB=D0=B0=D0=B2=D0=B8=D0=B0=D1=82=D1=83=D1=80=D1=8B?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/DbEditorPP/res/resource.rc | 4 +-- plugins/DbEditorPP/src/findwindow.cpp | 55 ++++++++++++++++++----------------- plugins/DbEditorPP/src/resource.h | 2 +- 3 files changed, 32 insertions(+), 29 deletions(-) diff --git a/plugins/DbEditorPP/res/resource.rc b/plugins/DbEditorPP/res/resource.rc index 947d3ad4d0..7ac896340d 100644 --- a/plugins/DbEditorPP/res/resource.rc +++ b/plugins/DbEditorPP/res/resource.rc @@ -32,7 +32,7 @@ BEGIN GROUPBOX "Search for",IDC_SEARCH2,4,1,387,45 EDITTEXT IDC_TEXT,10,11,232,12,ES_AUTOHSCROLL CONTROL "Exact match",IDC_EXACT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,249,12,69,8 - DEFPUSHBUTTON "&Search",IDC_SEARCH,325,10,60,14 + DEFPUSHBUTTON "&Search",IDOK,325,10,60,14 CONTROL "Module name",IDC_MODNAME,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,29,69,10 CONTROL "Setting name",IDC_SETTINGNAME,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,94,29,71,10 CONTROL "Setting value",IDC_SETTINGVALUE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,172,29,68,10 @@ -41,7 +41,7 @@ BEGIN GROUPBOX "Replace with",IDC_STATIC,4,47,387,28 EDITTEXT IDC_REPLACE,10,57,232,12,ES_AUTOHSCROLL CONTROL "Entirely",IDC_ENTIRELY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,249,58,69,10 - PUSHBUTTON "&Replace",IDOK,325,56,60,14 + PUSHBUTTON "&Replace",IDC_BTNREPLACE,325,56,60,14 CONTROL "List1",IDC_LIST,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_SORTDESCENDING | LVS_SHAREIMAGELISTS | LVS_AUTOARRANGE | WS_BORDER | WS_TABSTOP,4,80,387,152 CONTROL "",IDC_SBAR,"msctls_statusbar32",0x100,4,238,387,12 END diff --git a/plugins/DbEditorPP/src/findwindow.cpp b/plugins/DbEditorPP/src/findwindow.cpp index 46286bc7b0..b2eb901ff5 100644 --- a/plugins/DbEditorPP/src/findwindow.cpp +++ b/plugins/DbEditorPP/src/findwindow.cpp @@ -348,7 +348,7 @@ class CFindWindowDlg : public CDlgBase if (fi->replace) { pDlg->btnReplace.SetText(TranslateT("&Replace")); - pDlg->btnSearch.Enable(1); + pDlg->btnSearch.Enable(); } else { pDlg->btnSearch.SetText(TranslateT("&Search")); @@ -398,6 +398,22 @@ class CFindWindowDlg : public CDlgBase m_results.SetItemText(index, 4, value); } + void OpenSettings(int iItem) + { + ItemInfo ii = {}; + ii.hContact = (MCONTACT)m_results.GetItemData(iItem); + if (ii.hContact == -1) + return; + + ListView_GetItemTextA(m_results.GetHwnd(), iItem, 2, ii.module, _countof(ii.module)); + ListView_GetItemTextA(m_results.GetHwnd(), iItem, 3, ii.setting, _countof(ii.setting)); + if (ii.setting[0]) + ii.type = FW_SETTINGNAME; + else if (ii.module[0]) + ii.type = FW_MODULE; + SendMessage(hwnd2mainWindow, WM_FINDITEM, (WPARAM)&ii, 0); + } + CCtrlBase m_sb; CCtrlCheck chkModules, chkSettings, chkValues, chkReplaceAll, chkExactMatch, chkCaseSensitive; CCtrlButton btnSearch, btnReplace; @@ -408,8 +424,8 @@ public: CDlgBase(g_plugin, IDD_FIND), m_sb(this, IDC_SBAR), m_results(this, IDC_LIST), - btnReplace(this, IDOK), - btnSearch(this, IDC_SEARCH), + btnSearch(this, IDOK), + btnReplace(this, IDC_BTNREPLACE), chkModules(this, IDC_MODNAME), chkSettings(this, IDC_SETTINGNAME), chkValues(this, IDC_SETTINGVALUE), @@ -427,7 +443,7 @@ public: CreateLink(chkExactMatch, g_bExactMatch); CreateLink(chkCaseSensitive, g_bCaseSensitive); - btnSearch.OnClick = Callback(this, &CFindWindowDlg::onClick_Search); + btnReplace.OnClick = Callback(this, &CFindWindowDlg::onClick_Search); m_results.OnColumnClick = Callback(this, &CFindWindowDlg::onColumnClick_List); m_results.OnDoubleClick = Callback(this, &CFindWindowDlg::onDblClick_List); @@ -439,7 +455,7 @@ public: CheckDlgButton(m_hwnd, IDC_FOUND, BST_CHECKED); SendMessage(m_hwnd, WM_SETICON, ICON_BIG, (LPARAM)LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(ICO_REGEDIT))); SetWindowLong(m_hwnd, GWL_EXSTYLE, GetWindowLong(m_hwnd, GWL_EXSTYLE) | WS_EX_APPWINDOW); // taskbar icon - m_results.SetExtendedListViewStyle(32 | LVS_EX_LABELTIP); // LVS_EX_GRIDLINES + m_results.SetExtendedListViewStyle(LVS_EX_FULLROWSELECT | LVS_EX_LABELTIP); // LVS_EX_GRIDLINES loadListSettings(m_results.GetHwnd(), csResultList); Utils_RestoreWindowPositionNoMove(m_hwnd, NULL, MODULENAME, "Search_"); return true; @@ -447,7 +463,10 @@ public: bool OnApply() override { - onClick_Search(0); + if (::GetFocus() == m_results.GetHwnd()) + OpenSettings(m_results.GetSelectionMark()); + else + onClick_Search(&btnSearch); return false; } @@ -486,7 +505,7 @@ public: // empty replace is done only for exact match or entire replace wchar_t replace[FLD_SIZE] = {}; - if (pButton->GetCtrlId() == IDOK && !GetDlgItemText(m_hwnd, IDC_REPLACE, replace, _countof(replace)) && !g_bReplaceAll && !g_bExactMatch) + if (pButton == &btnReplace && !GetDlgItemText(m_hwnd, IDC_REPLACE, replace, _countof(replace)) && !g_bReplaceAll && !g_bExactMatch) return; if (!g_bSearchModule && !g_bSearchSetting && !g_bSearchValues) @@ -496,7 +515,7 @@ public: fi->pDlg = this; fi->options = (g_bCaseSensitive ? F_CASE : 0) | (g_bExactMatch ? F_EXACT : 0) | (g_bSearchModule ? F_MODNAME : 0) | (g_bSearchSetting ? F_SETNAME : 0) | (g_bSearchValues ? F_SETVAL : 0); - if (pButton->GetCtrlId() == IDOK) { + if (pButton == &btnReplace) { if (g_bReplaceAll) fi->options |= F_ENTIRE; @@ -526,24 +545,8 @@ public: if (m_results.SubItemHitTest(&hti) == -1) return; - if (hti.flags & LVHT_ONITEM) { - LVITEM lvi; - lvi.mask = LVIF_PARAM; - lvi.iItem = hti.iItem; - lvi.iSubItem = 0; - if (m_results.GetItem(&lvi)) { - ItemInfo ii = {}; - ii.hContact = (MCONTACT)lvi.lParam; - ListView_GetItemTextA(m_results.GetHwnd(), hti.iItem, 2, ii.module, _countof(ii.module)); - ListView_GetItemTextA(m_results.GetHwnd(), hti.iItem, 3, ii.setting, _countof(ii.setting)); - if (ii.setting[0]) - ii.type = FW_SETTINGNAME; - else if (ii.module[0]) - ii.type = FW_MODULE; - - SendMessage(hwnd2mainWindow, WM_FINDITEM, (WPARAM)&ii, 0); - } - } + if (hti.flags & LVHT_ONITEM) + OpenSettings(hti.iItem); } void onColumnClick_List(CCtrlListView::TEventInfo *ev) diff --git a/plugins/DbEditorPP/src/resource.h b/plugins/DbEditorPP/src/resource.h index cd785d9e54..43afec172a 100644 --- a/plugins/DbEditorPP/src/resource.h +++ b/plugins/DbEditorPP/src/resource.h @@ -65,10 +65,10 @@ #define IDC_ARRAYSIZE 1030 #define IDC_CURRENTSIZE 1032 #define IDC_INFOTEXT 1033 +#define IDC_BTNREPLACE 1034 #define IDC_CRLF 1035 #define IDC_CASESENSITIVE 1040 #define IDC_LIST 1041 -#define IDC_SEARCH 1042 #define IDC_EXACT 1043 #define IDC_EXPANDSETTINGS 1044 #define IDC_SEARCH2 1045 -- cgit v1.2.3