summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/m_srmm_int.h2
-rw-r--r--src/mir_app/src/srmm_log_rtf.cpp18
-rw-r--r--src/mir_app/src/srmm_main.cpp18
3 files changed, 20 insertions, 18 deletions
diff --git a/include/m_srmm_int.h b/include/m_srmm_int.h
index 2ed23a5bf7..75f1185f81 100644
--- a/include/m_srmm_int.h
+++ b/include/m_srmm_int.h
@@ -180,6 +180,8 @@ struct RtfChatLogStreamData
class MIR_APP_EXPORT CRtfLogWindow : public CSrmmLogWindow
{
+ HANDLE hevDelete, hevEdited;
+
protected:
CCtrlRichEdit &m_rtf;
diff --git a/src/mir_app/src/srmm_log_rtf.cpp b/src/mir_app/src/srmm_log_rtf.cpp
index 6a879a535f..ee76d28bc3 100644
--- a/src/mir_app/src/srmm_log_rtf.cpp
+++ b/src/mir_app/src/srmm_log_rtf.cpp
@@ -30,14 +30,32 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define EVENTTYPE_STATUSCHANGE 25368
#define EVENTTYPE_ERRMSG 25366
+static int OnRedrawLog(void *pObj, WPARAM hContact, LPARAM)
+{
+ auto *pLog = (CRtfLogWindow *)pObj;
+ auto &pDlg = pLog->GetDialog();
+
+ if (pDlg.m_hContact == hContact)
+ pDlg.ScheduleRedrawLog();
+ else if (auto hParent = db_mc_getMeta(hContact))
+ if (pDlg.m_hContact == hParent)
+ pDlg.ScheduleRedrawLog();
+
+ return 0;
+}
+
CRtfLogWindow::CRtfLogWindow(CMsgDialog &pDlg) :
CSrmmLogWindow(pDlg),
m_rtf(*(CCtrlRichEdit*)pDlg.FindControl(IDC_SRMM_LOG))
{
+ hevEdited = HookEventObj(ME_DB_EVENT_EDITED, OnRedrawLog, this);
+ hevDelete = HookEventObj(ME_DB_EVENT_DELETED, OnRedrawLog, this);
}
CRtfLogWindow::~CRtfLogWindow()
{
+ UnhookEvent(hevEdited);
+ UnhookEvent(hevDelete);
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/mir_app/src/srmm_main.cpp b/src/mir_app/src/srmm_main.cpp
index 9de2c1bdb0..54fe37b369 100644
--- a/src/mir_app/src/srmm_main.cpp
+++ b/src/mir_app/src/srmm_main.cpp
@@ -52,21 +52,6 @@ static int OnPrebuildContactMenu(WPARAM hContact, LPARAM)
}
/////////////////////////////////////////////////////////////////////////////////////////
-// Built-in hook to redraw RTF-based event logs on event's change/deletion
-
-static int OnRedrawLog(WPARAM hContact, LPARAM)
-{
- if (auto *pDlg = Srmm_FindDialog(hContact))
- pDlg->ScheduleRedrawLog();
-
- if (db_mc_isSub(hContact))
- if (auto *pDlg = Srmm_FindDialog(db_mc_getMeta(hContact)))
- pDlg->ScheduleRedrawLog();
-
- return 0;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
void SrmmModulesLoaded()
{
@@ -104,9 +89,6 @@ int LoadSrmmModule()
hHookSrmmEvent = CreateHookableEvent(ME_MSG_WINDOWEVENT);
hHookIconsChanged = CreateHookableEvent(ME_MSG_ICONSCHANGED);
hHookIconPressedEvt = CreateHookableEvent(ME_MSG_ICONPRESSED);
-
- HookEvent(ME_DB_EVENT_EDITED, OnRedrawLog);
- HookEvent(ME_DB_EVENT_DELETED, OnRedrawLog);
return 0;
}