summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/stdmsg/src/msgdialog.cpp46
-rw-r--r--src/core/stdmsg/src/msgs.h2
2 files changed, 26 insertions, 22 deletions
diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp
index ee22d04648..386552ee78 100644
--- a/src/core/stdmsg/src/msgdialog.cpp
+++ b/src/core/stdmsg/src/msgdialog.cpp
@@ -198,15 +198,20 @@ void CSrmmWindow::OnInitDialog()
MEVENT hdbEvent = db_event_last(m_hContact);
if (hdbEvent) {
+ bool bUpdate = false;
do {
DBEVENTINFO dbei = {};
db_event_get(hdbEvent, &dbei);
if ((dbei.eventType == EVENTTYPE_MESSAGE) && !(dbei.flags & DBEF_SENT)) {
m_lastMessage = dbei.timestamp;
- PostMessage(m_hwnd, DM_UPDATELASTMESSAGE, 0, 0);
+ bUpdate = true;
break;
}
- } while (hdbEvent = db_event_prev(m_hContact, hdbEvent));
+ }
+ while (hdbEvent = db_event_prev(m_hContact, hdbEvent));
+
+ if (bUpdate)
+ UpdateLastMessage();
}
OnOptionsApplied(false);
@@ -596,6 +601,21 @@ void CSrmmWindow::UpdateIcon(WPARAM wParam)
}
}
+void CSrmmWindow::UpdateLastMessage()
+{
+ if (m_nTypeSecs)
+ return;
+
+ if (m_lastMessage) {
+ wchar_t date[64], time[64], fmt[128];
+ TimeZone_PrintTimeStamp(nullptr, m_lastMessage, L"d", date, _countof(date), 0);
+ TimeZone_PrintTimeStamp(nullptr, m_lastMessage, L"t", time, _countof(time), 0);
+ mir_snwprintf(fmt, TranslateT("Last message received on %s at %s."), date, time);
+ SetStatusText(fmt, nullptr);
+ }
+ else SetStatusText(nullptr, nullptr);
+}
+
void CSrmmWindow::UpdateReadChars()
{
if (g_dat.bShowReadChar) {
@@ -1037,22 +1057,6 @@ INT_PTR CSrmmWindow::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
}
break;
- case DM_UPDATELASTMESSAGE:
- if (m_nTypeSecs)
- break;
-
- if (m_lastMessage) {
- wchar_t date[64], time[64], fmt[128];
- TimeZone_PrintTimeStamp(nullptr, m_lastMessage, L"d", date, _countof(date), 0);
- TimeZone_PrintTimeStamp(nullptr, m_lastMessage, L"t", time, _countof(time), 0);
- mir_snwprintf(fmt, TranslateT("Last message received on %s at %s."), date, time);
- SendMessage(m_pOwner->m_hwndStatus, SB_SETTEXT, 0, (LPARAM)fmt);
- }
- else SendMessage(m_pOwner->m_hwndStatus, SB_SETTEXT, 0, (LPARAM)L"");
-
- SendMessage(m_pOwner->m_hwndStatus, SB_SETICON, 0, 0);
- break;
-
case DM_OPTIONSAPPLIED:
OnOptionsApplied(wParam != 0);
break;
@@ -1084,7 +1088,7 @@ INT_PTR CSrmmWindow::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
// fall through
case WM_MOUSEACTIVATE:
UpdateTitle();
- SendMessage(m_hwnd, DM_UPDATELASTMESSAGE, 0, 0);
+ UpdateLastMessage();
if (KillTimer(m_hwnd, TIMERID_FLASHWND))
FlashWindow(m_pOwner->GetHwnd(), FALSE);
break;
@@ -1152,7 +1156,7 @@ INT_PTR CSrmmWindow::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
}
if (isMessage && !isSent) {
m_lastMessage = dbei.timestamp;
- SendMessage(m_hwnd, DM_UPDATELASTMESSAGE, 0, 0);
+ UpdateLastMessage();
}
if (hDbEvent != m_hDbEventFirst && db_event_next(m_hContact, hDbEvent) == 0)
SendMessage(m_hwnd, DM_APPENDTOLOG, hDbEvent, 0);
@@ -1204,7 +1208,7 @@ INT_PTR CSrmmWindow::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
SendMessage(m_hwnd, DM_UPDATEWINICON, 0, 0);
}
else {
- SendMessage(m_hwnd, DM_UPDATELASTMESSAGE, 0, 0);
+ UpdateLastMessage();
if (g_dat.bShowTypingWin)
SendMessage(m_hwnd, DM_UPDATEWINICON, 0, 0);
m_bShowTyping = false;
diff --git a/src/core/stdmsg/src/msgs.h b/src/core/stdmsg/src/msgs.h
index 57acc69dd6..75c64c69cb 100644
--- a/src/core/stdmsg/src/msgs.h
+++ b/src/core/stdmsg/src/msgs.h
@@ -32,7 +32,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define DM_NEWTIMEZONE (WM_USER+18)
#define DM_TYPING (WM_USER+20)
#define DM_UPDATEWINICON (WM_USER+21)
-#define DM_UPDATELASTMESSAGE (WM_USER+22)
#define DM_USERNAMETOCLIP (WM_USER+23)
#define DM_AVATARSIZECHANGE (WM_USER+24)
#define DM_AVATARCALCSIZE (WM_USER+25)
@@ -77,6 +76,7 @@ class CSrmmWindow : public CMsgDialog
void SetupStatusBar(void);
void StreamInEvents(MEVENT hDbEventFirst, int count, bool bAppend);
void UpdateIcon(WPARAM wParam);
+ void UpdateLastMessage(void);
char *m_szProto;
HICON m_hStatusIcon = nullptr;