From 3beaf647c5b9a991d713ebbc67c5ba81e911840d Mon Sep 17 00:00:00 2001 From: troiganto Date: Thu, 5 Jun 2014 16:17:46 +0200 Subject: [PATCH] Tweaked the "caption of the window under the cursor" text box. The box now is enabled, read-only, and borderless. It now gets only updated if the caption changes. --- AutoSave/AutoSave.rc | 2 +- AutoSave_libs/OptionsPageTarget.cpp | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/AutoSave/AutoSave.rc b/AutoSave/AutoSave.rc index 4dcde0c..c0fa31b 100644 --- a/AutoSave/AutoSave.rc +++ b/AutoSave/AutoSave.rc @@ -91,7 +91,7 @@ FONT 8, "Ms Shell Dlg" LTEXT "Currently open windows that would match:", 3, 7, 52, 201, 8, SS_LEFT, WS_EX_TRANSPARENT LISTBOX IDC_SETTINGS_WINDOWLIST, 7, 62, 201, 127, LBS_NOINTEGRALHEIGHT | LBS_HASSTRINGS | LBS_NOSEL | LBS_SORT | LBS_USETABSTOPS | LBS_NOTIFY, WS_EX_LEFT LTEXT "Caption of the window under the mouse cursor:", 5, 7, 196, 201, 8, SS_LEFT, WS_EX_TRANSPARENT - EDITTEXT IDC_SETTINGS_CURWINEDIT, 7, 206, 201, 14, WS_DISABLED | ES_AUTOHSCROLL | ES_READONLY, WS_EX_LEFT + EDITTEXT IDC_SETTINGS_CURWINEDIT, 7, 206, 201, 14, NOT WS_BORDER | ES_AUTOHSCROLL | ES_READONLY, WS_EX_LEFT } diff --git a/AutoSave_libs/OptionsPageTarget.cpp b/AutoSave_libs/OptionsPageTarget.cpp index 12f971d..b7dbc0b 100644 --- a/AutoSave_libs/OptionsPageTarget.cpp +++ b/AutoSave_libs/OptionsPageTarget.cpp @@ -232,14 +232,26 @@ void OptionsPageTarget::onTimer(UINT_PTR timerId) void OptionsPageTarget::updateCurrentWindowCaptionEdit() { + // Naive approach would fuck with the text selection. + static wstring currentText; + POINT point; GetCursorPos(&point); HWND window = ChildWindowFromPointEx( GetDesktopWindow(), point, CWP_SKIPINVISIBLE); - - SetDlgItemText(m_hwnd, IDC_SETTINGS_CURWINEDIT, - Matcher::getWindowText(window).data()); + /* Maybe the following is a good addition? + if (window == GetParent(m_hwnd)) + return; + */ + + wstring newText = Matcher::getWindowText(window); + if (newText != currentText) + { + currentText = newText; + SetDlgItemText(m_hwnd, IDC_SETTINGS_CURWINEDIT, + currentText.data()); + } }