Skip to content

Commit 7fa200f

Browse files
committed
notepad.prompt() window and multiline input #261
- avoid that input text in prompt edit control is automatically selected
1 parent 84c41d8 commit 7fa200f

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

PythonScript/src/PromptDialog.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,10 @@ INT_PTR CALLBACK PromptDialog::dlgProc(HWND hWnd, UINT message, WPARAM wParam, L
4646
default:
4747
{
4848
PromptDialog* dlg = reinterpret_cast<PromptDialog*>(::GetWindowLongPtr(hWnd, GWLP_USERDATA));
49-
if (dlg)
49+
if (dlg)
5050
return dlg->runDlgProc(hWnd, message, wParam, lParam);
5151
else
5252
return TRUE;
53-
5453
}
5554
}
5655
}
@@ -67,11 +66,14 @@ INT_PTR CALLBACK PromptDialog::runDlgProc(HWND hWnd, UINT message, WPARAM wParam
6766
::SetWindowText(m_hSelf, WcharMbcsConverter::char2tchar(m_title.c_str()).get());
6867
::SetWindowText(::GetDlgItem(m_hSelf, IDC_USERTEXT), WcharMbcsConverter::char2tchar(m_initial.c_str()).get());
6968
::SendMessage(::GetDlgItem(m_hSelf, IDC_USERTEXT), EM_SETSEL, 0, -1);
69+
//disable selection and set cursor to end of text also if scrolling is necessary for long text
70+
::SendMessage(::GetDlgItem(m_hSelf, IDC_USERTEXT), EM_SETSEL, static_cast<WPARAM>(-1), -1);
71+
::SendMessage(::GetDlgItem(m_hSelf, IDC_USERTEXT), EM_SCROLLCARET, 0, 0);
7072
SetFocus(::GetDlgItem(m_hSelf, IDC_USERTEXT));
7173

72-
RECT rc;
74+
RECT rc;
7375
::GetClientRect(m_hNotepad, &rc);
74-
POINT center;
76+
POINT center{};
7577
center.x = rc.left + (rc.right - rc.left)/2;
7678
center.y = rc.top + (rc.bottom - rc.top)/2;
7779
::ClientToScreen(m_hNotepad, &center);

0 commit comments

Comments
 (0)