summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2017-04-06 17:40:31 +0300
committerGeorge Hazan <ghazan@miranda.im>2017-04-06 17:40:31 +0300
commit9e1863b5fd706dafef290d6d78b06068d82e0dbe (patch)
tree21e0ff0a0635466ec551333a86a6a7c16b0ac38b /src
parent379c01d539737afbe1c32e09a492a240400774e4 (diff)
message cleaning
Diffstat (limited to 'src')
-rw-r--r--src/core/stdmsg/src/msgdialog.cpp49
-rw-r--r--src/core/stdmsg/src/msglog.cpp5
-rw-r--r--src/core/stdmsg/src/msgs.h4
3 files changed, 27 insertions, 31 deletions
diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp
index 4ae0a330dd..f855ec9c6b 100644
--- a/src/core/stdmsg/src/msgdialog.cpp
+++ b/src/core/stdmsg/src/msgdialog.cpp
@@ -102,6 +102,7 @@ static void SetEditorText(HWND hwnd, const wchar_t* txt)
CSrmmWindow::CSrmmWindow(MCONTACT hContact) :
CSrmmBaseDialog(g_hInst, IDD_MSG),
m_splitter(this, IDC_SPLITTERY),
+ m_avatar(this, IDC_AVATAR),
m_btnOk(this, IDOK),
m_cmdList(20),
m_bNoActivate(g_dat.bDoNotStealFocus)
@@ -159,7 +160,7 @@ void CSrmmWindow::OnInitDialog()
SendMessage(m_hwnd, DM_UPDATESIZEBAR, 0, 0);
m_hwndStatus = nullptr;
- EnableWindow(GetDlgItem(m_hwnd, IDC_AVATAR), FALSE);
+ m_avatar.Enable(false);
m_log.SendMsg(EM_SETOLECALLBACK, 0, (LPARAM)&reOleCallback);
m_log.SendMsg(EM_SETEVENTMASK, 0, ENM_MOUSEEVENTS | ENM_LINK | ENM_SCROLL);
@@ -395,7 +396,7 @@ void CSrmmWindow::OnOptionsApplied(bool bUpdateAvatar)
m_btnOk.Show(g_dat.bSendButton);
m_btnOk.Enable(GetWindowTextLength(m_message.GetHwnd()) != 0);
if (m_avatarPic == nullptr || !g_dat.bShowAvatar)
- ShowWindow(GetDlgItem(m_hwnd, IDC_AVATAR), SW_HIDE);
+ m_avatar.Hide();
SendMessage(m_hwnd, DM_UPDATETITLE, 0, 0);
SendMessage(m_hwnd, WM_SIZE, 0, 0);
@@ -503,6 +504,21 @@ void CSrmmWindow::NotifyTyping(int mode)
CallService(MS_PROTO_SELFISTYPING, m_hContact, m_nTypeMode);
}
+void CSrmmWindow::ScrollToBottom()
+{
+ if (!(GetWindowLongPtr(m_log.GetHwnd(), GWL_STYLE) & WS_VSCROLL))
+ return;
+
+ SCROLLINFO si = {};
+ si.cbSize = sizeof(si);
+ si.fMask = SIF_PAGE | SIF_RANGE;
+ GetScrollInfo(m_log.GetHwnd(), SB_VERT, &si);
+ si.fMask = SIF_POS;
+ si.nPos = si.nMax - si.nPage;
+ SetScrollInfo(m_log.GetHwnd(), SB_VERT, &si, TRUE);
+ m_log.SendMsg(WM_VSCROLL, MAKEWPARAM(SB_BOTTOM, 0), 0);
+}
+
void CSrmmWindow::ShowAvatar()
{
if (g_dat.bShowAvatar) {
@@ -881,7 +897,7 @@ INT_PTR CSrmmWindow::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
if (m_avatarPic == nullptr || !g_dat.bShowAvatar) {
m_avatarWidth = 50;
m_avatarHeight = 50;
- ShowWindow(GetDlgItem(m_hwnd, IDC_AVATAR), SW_HIDE);
+ m_avatar.Hide();
return 0;
}
else {
@@ -893,7 +909,7 @@ INT_PTR CSrmmWindow::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
m_avatarWidth = bminfo.bmWidth * m_limitAvatarH / bminfo.bmHeight + 2;
m_avatarHeight = m_limitAvatarH + 2;
}
- ShowWindow(GetDlgItem(m_hwnd, IDC_AVATAR), SW_SHOW);
+ m_avatar.Show();
}
break;
@@ -1087,15 +1103,15 @@ INT_PTR CSrmmWindow::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
// The statusbar sometimes draws over these 2 controls so
// redraw them
if (m_hwndStatus) {
- RedrawWindow(GetDlgItem(m_hwnd, IDOK), nullptr, nullptr, RDW_INVALIDATE);
+ RedrawWindow(m_btnOk.GetHwnd(), nullptr, nullptr, RDW_INVALIDATE);
RedrawWindow(m_message.GetHwnd(), nullptr, nullptr, RDW_INVALIDATE);
}
if (g_dat.bShowAvatar && m_avatarPic)
- RedrawWindow(GetDlgItem(m_hwnd, IDC_AVATAR), nullptr, nullptr, RDW_INVALIDATE);
+ RedrawWindow(m_avatar.GetHwnd(), nullptr, nullptr, RDW_INVALIDATE);
if (bottomScroll)
- PostMessage(m_hwnd, DM_SCROLLLOGTOBOTTOM, 0, 0);
+ ScrollToBottom();
}
return TRUE;
@@ -1103,23 +1119,6 @@ INT_PTR CSrmmWindow::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
StreamInEvents(m_hDbEventFirst, -1, 0);
break;
- case DM_APPENDTOLOG: //takes wParam=hDbEvent
- StreamInEvents(wParam, 1, 1);
- break;
-
- case DM_SCROLLLOGTOBOTTOM:
- if (GetWindowLongPtr(m_log.GetHwnd(), GWL_STYLE) & WS_VSCROLL) {
- SCROLLINFO si = {};
- si.cbSize = sizeof(si);
- si.fMask = SIF_PAGE | SIF_RANGE;
- GetScrollInfo(m_log.GetHwnd(), SB_VERT, &si);
- si.fMask = SIF_POS;
- si.nPos = si.nMax - si.nPage;
- SetScrollInfo(m_log.GetHwnd(), SB_VERT, &si, TRUE);
- m_log.SendMsg(WM_VSCROLL, MAKEWPARAM(SB_BOTTOM, 0), 0);
- }
- break;
-
case HM_DBEVENTADDED:
if (wParam == m_hContact) {
MEVENT hDbEvent = lParam;
@@ -1142,7 +1141,7 @@ INT_PTR CSrmmWindow::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
SendMessage(m_hwnd, DM_UPDATELASTMESSAGE, 0, 0);
}
if (hDbEvent != m_hDbEventFirst && db_event_next(m_hContact, hDbEvent) == 0)
- SendMessage(m_hwnd, DM_APPENDTOLOG, lParam, 0);
+ StreamInEvents(hDbEvent, 1, 1);
else
SendMessage(m_hwnd, DM_REMAKELOG, 0, 0);
diff --git a/src/core/stdmsg/src/msglog.cpp b/src/core/stdmsg/src/msglog.cpp
index a2250afaad..fb5b1e2fd9 100644
--- a/src/core/stdmsg/src/msglog.cpp
+++ b/src/core/stdmsg/src/msglog.cpp
@@ -436,10 +436,7 @@ void CSrmmWindow::StreamInEvents(MEVENT hDbEventFirst, int count, bool bAppend)
if (bottomScroll) {
sel.cpMin = sel.cpMax = -1;
m_log.SendMsg(EM_EXSETSEL, 0, (LPARAM)&sel);
- if (GetWindowLongPtr(m_log.GetHwnd(), GWL_STYLE) & WS_VSCROLL) {
- SendMessage(m_hwnd, DM_SCROLLLOGTOBOTTOM, 0, 0);
- PostMessage(m_hwnd, DM_SCROLLLOGTOBOTTOM, 0, 0);
- }
+ ScrollToBottom();
}
else {
m_log.SendMsg(EM_EXSETSEL, 0, (LPARAM)&oldSel);
diff --git a/src/core/stdmsg/src/msgs.h b/src/core/stdmsg/src/msgs.h
index 7976d3eca9..e7a9ee5076 100644
--- a/src/core/stdmsg/src/msgs.h
+++ b/src/core/stdmsg/src/msgs.h
@@ -30,9 +30,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define DM_CASCADENEWWINDOW (WM_USER+13)
#define DM_OPTIONSAPPLIED (WM_USER+14)
#define DM_UPDATETITLE (WM_USER+16)
-#define DM_APPENDTOLOG (WM_USER+17)
#define DM_NEWTIMEZONE (WM_USER+18)
-#define DM_SCROLLLOGTOBOTTOM (WM_USER+19)
#define DM_TYPING (WM_USER+20)
#define DM_UPDATEWINICON (WM_USER+21)
#define DM_UPDATELASTMESSAGE (WM_USER+22)
@@ -56,6 +54,7 @@ class CSrmmWindow : public CSrmmBaseDialog
virtual LRESULT WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) override;
+ CCtrlBase m_avatar;
CCtrlButton m_btnOk;
CSplitter m_splitter;
@@ -108,6 +107,7 @@ public:
virtual int Resizer(UTILRESIZECONTROL *urc) override;
virtual void LoadSettings() override {}
+ virtual void ScrollToBottom() override;
virtual void UpdateTitle() override {}
void OnSplitterMoved(CSplitter*);