Skip to content

Commit

Permalink
Tweaked the "caption of the window under the cursor" text box.
Browse files Browse the repository at this point in the history
The box now is enabled, read-only, and borderless.
It now gets only updated if the caption changes.
  • Loading branch information
troiganto committed Jun 5, 2014
1 parent 70df714 commit 3beaf64
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion AutoSave/AutoSave.rc
Original file line number Diff line number Diff line change
Expand Up @@ -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
}


Expand Down
18 changes: 15 additions & 3 deletions AutoSave_libs/OptionsPageTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}


Expand Down

0 comments on commit 3beaf64

Please sign in to comment.