From 72a9d1ef8e3a3d936b8abc123ced461feeb92ea5 Mon Sep 17 00:00:00 2001 From: RaiKoHoff Date: Mon, 31 Aug 2020 15:53:05 +0200 Subject: [PATCH] + chg: grepWinNP3: alpha transparency on losing focus --- grepWinNP3/src/SearchDlg.cpp | 18 ++++++++++++++++++ grepWinNP3/src/SearchDlg.h | 6 +++++- src/Dialogs.c | 3 +++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/grepWinNP3/src/SearchDlg.cpp b/grepWinNP3/src/SearchDlg.cpp index 996dac2ed..34263f75d 100644 --- a/grepWinNP3/src/SearchDlg.cpp +++ b/grepWinNP3/src/SearchDlg.cpp @@ -168,6 +168,7 @@ CSearchDlg::CSearchDlg(HWND hParent) , m_regDate2Low(L"Software\\grepWinNP3\\Date2Low", 0) , m_regDate2High(L"Software\\grepWinNP3\\Date2High", 0) , m_regShowContent(L"Software\\grepWinNP3\\ShowContent", 0) + , m_regTranspAlphaNoFocus(L"Software\\grepWinNP3\\TranspAlphaNoFocus", 100) , m_AutoCompleteFilePatterns(bPortable ? &g_iniFile : nullptr) , m_AutoCompleteExcludeDirsPatterns(bPortable ? &g_iniFile : nullptr) , m_AutoCompleteSearchPatterns(bPortable ? &g_iniFile : nullptr) @@ -207,6 +208,7 @@ LRESULT CSearchDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara { case WM_INITDIALOG: { + SetTransparency(ALPHA_OPAQUE); SHAutoComplete(GetDlgItem(*this, IDC_SEARCHPATH), SHACF_FILESYSTEM|SHACF_AUTOSUGGEST_FORCE_ON); m_AutoCompleteFilePatterns.Load(L"Software\\grepWinNP3\\History", L"FilePattern"); @@ -395,6 +397,8 @@ LRESULT CSearchDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara m_bUseRegex = (bPortable ? g_iniFile.GetBoolValue(L"global", L"UseRegex", false) : DWORD(m_regUseRegex)); + m_TranspAlphaNoFocus = (BYTE)(bPortable ? g_iniFile.GetLongValue(L"global", L"TranspAlphaNoFocus", 80) : DWORD(m_regTranspAlphaNoFocus)); + SendDlgItemMessage(hwndDlg, IDC_SIZECOMBO, CB_SETCURSEL, m_sizeCmp, 0); SendDlgItemMessage(hwndDlg, IDC_INCLUDESUBFOLDERS, BM_SETCHECK, m_bIncludeSubfolders ? BST_CHECKED : BST_UNCHECKED, 0); @@ -903,6 +907,20 @@ LRESULT CSearchDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara } } break; + case WM_ACTIVATE: + switch (LOWORD(wParam)) + { + case WA_INACTIVE: + SetTransparency(m_TranspAlphaNoFocus); + break; + + case WA_CLICKACTIVE: + // mouse click activation + case WA_ACTIVE: + SetTransparency(ALPHA_OPAQUE); + break; + } + break; default: return FALSE; } diff --git a/grepWinNP3/src/SearchDlg.h b/grepWinNP3/src/SearchDlg.h index 6577eaf4d..0ff9a6fcf 100644 --- a/grepWinNP3/src/SearchDlg.h +++ b/grepWinNP3/src/SearchDlg.h @@ -41,7 +41,9 @@ #define SEARCH_END (WM_APP+3) #define WM_GREPWIN_THREADEND (WM_APP+4) -#define ID_ABOUTBOX 0x0010 +#define ID_ABOUTBOX (0x0010) + +#define ALPHA_OPAQUE (255) enum ExecuteAction { @@ -203,6 +205,7 @@ private: bool m_bConfirmationOnReplace; bool m_showContent; bool m_showContentSet; + BYTE m_TranspAlphaNoFocus; std::vector m_items; std::vector> m_listItems; @@ -262,4 +265,5 @@ private: CRegStdDWORD m_regDate2Low; CRegStdDWORD m_regDate2High; CRegStdDWORD m_regShowContent; + CRegStdDWORD m_regTranspAlphaNoFocus; }; diff --git a/src/Dialogs.c b/src/Dialogs.c index 586b460d9..8a64b4a5a 100644 --- a/src/Dialogs.c +++ b/src/Dialogs.c @@ -3764,6 +3764,9 @@ void DialogGrepWin(HWND hwnd, LPCWSTR searchPattern) StringCchPrintf(tchTemp, COUNTOF(tchTemp), L"%s /%%mode%% \"%%pattern%%\" /g %%line%% - %%path%%", tchNotepad3Path); IniSectionSetString(globalSection, L"editorcmd", tchTemp); + long const iTranspAlpha = IniSectionGetLong(globalSection, L"TranspAlphaNoFocus", MulDiv(Settings2.FindReplaceOpacityLevel, 255, 100)); + IniSectionSetLong(globalSection, L"TranspAlphaNoFocus", iTranspAlpha); + // [settings] const WCHAR *const settingsSection = L"settings";