diff options
author | George Hazan <ghazan@miranda.im> | 2019-09-04 16:11:19 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-09-04 16:11:19 +0300 |
commit | 08b67343eaa3d4848f284b0be09d4a18c3b5f79d (patch) | |
tree | a856006ad62120786654e8d23eecbd003eebcf92 /src/core/stdmsg | |
parent | dc813825f1abbaccc929a21d0ca98807d912aa4e (diff) |
more correct way of working with Ctrl+Up/Down
Diffstat (limited to 'src/core/stdmsg')
-rw-r--r-- | src/core/stdmsg/src/msgdialog.cpp | 47 |
1 files changed, 22 insertions, 25 deletions
diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp index 5cb644f9a4..0bea99d46a 100644 --- a/src/core/stdmsg/src/msgdialog.cpp +++ b/src/core/stdmsg/src/msgdialog.cpp @@ -59,12 +59,6 @@ static void AddToFileList(wchar_t ***pppFiles, int &totalCount, const wchar_t *s }
}
-static void SetEditorText(HWND hwnd, const wchar_t *txt)
-{
- SetWindowText(hwnd, txt);
- SendMessage(hwnd, EM_SETSEL, -1, -1);
-}
-
/////////////////////////////////////////////////////////////////////////////////////////
CMsgDialog::CMsgDialog(CTabbedWindow *pOwner, MCONTACT hContact) :
@@ -1330,31 +1324,34 @@ LRESULT CMsgDialog::WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) return 0;
}
- if (isCtrl && g_dat.bCtrlSupport && !g_dat.bAutoClose) {
- if (wParam == VK_UP) {
- if (m_cmdList.getCount()) {
- if (m_cmdListInd < 0) {
- m_cmdListInd = m_cmdList.getCount() - 1;
- SetEditorText(m_message.GetHwnd(), m_cmdList[m_cmdListInd]);
- }
- else if (m_cmdListInd > 0) {
- SetEditorText(m_message.GetHwnd(), m_cmdList[--m_cmdListInd]);
- }
- }
+ if (isCtrl && g_dat.bCtrlSupport && m_cmdList.getCount()) {
+ if (wParam == VK_UP && m_cmdListInd != 0) {
+ if (m_cmdListInd < 0)
+ m_cmdListInd = m_cmdList.getCount() - 1;
+ else
+ m_cmdListInd--;
+
+ m_message.SetText(m_cmdList[m_cmdListInd]);
+ m_message.SendMsg(EM_SETSEL, -1, -1);
+
m_btnOk.Enable(GetWindowTextLength(m_message.GetHwnd()) != 0);
UpdateReadChars();
return 0;
}
- if (wParam == VK_DOWN) {
- if (m_cmdList.getCount() && m_cmdListInd >= 0) {
- if (m_cmdListInd < m_cmdList.getCount() - 1)
- SetEditorText(m_message.GetHwnd(), m_cmdList[++m_cmdListInd]);
- else {
- m_cmdListInd = -1;
- SetEditorText(m_message.GetHwnd(), m_cmdList[m_cmdList.getCount() - 1]);
- }
+ if (wParam == VK_DOWN && m_cmdListInd != -1) {
+ const wchar_t *pwszText;
+ if (m_cmdListInd == m_cmdList.getCount() - 1) {
+ m_cmdListInd = -1;
+ pwszText = L"";
}
+ else {
+ m_cmdListInd++;
+ pwszText = m_cmdList[m_cmdListInd];
+ }
+
+ m_message.SetText(pwszText);
+ m_message.SendMsg(EM_SETSEL, -1, -1);
m_btnOk.Enable(GetWindowTextLength(m_message.GetHwnd()) != 0);
UpdateReadChars();
|