From b9a3a98d6f2695a36ca27fa2d88e99fedd72cc98 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 10 Mar 2017 21:46:59 +0300 Subject: Group chats: - GC_CONTROL_MSG left us forever; - tons of old/unused/useless slack simply wiped out; - new function: CSrmmBaseDialog::ClearLog --- plugins/Scriver/src/chat/window.cpp | 62 +---------- plugins/Scriver/src/msgdialog.cpp | 4 +- plugins/Scriver/src/msglog.cpp | 2 +- plugins/Scriver/src/msgs.cpp | 16 --- plugins/Scriver/src/msgs.h | 2 - plugins/TabSRMM/src/chat_log.cpp | 77 ++++++------- plugins/TabSRMM/src/chat_window.cpp | 165 +++++++++------------------- plugins/TabSRMM/src/generic_msghandlers.cpp | 6 +- plugins/TabSRMM/src/msgdialog.cpp | 15 +-- plugins/TabSRMM/src/msgs.h | 13 +-- plugins/TabSRMM/src/taskbar.cpp | 2 +- 11 files changed, 105 insertions(+), 259 deletions(-) (limited to 'plugins') diff --git a/plugins/Scriver/src/chat/window.cpp b/plugins/Scriver/src/chat/window.cpp index 7b88b9ddf5..0db9074563 100644 --- a/plugins/Scriver/src/chat/window.cpp +++ b/plugins/Scriver/src/chat/window.cpp @@ -1378,7 +1378,7 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) } else Log_StreamInEvent(m_si->pLogEnd, TRUE); } - else SendMessage(m_hwnd, GC_CONTROL_MSG, WINDOW_CLEARLOG, 0); + else ClearLog(); break; case GC_REDRAWLOG2: @@ -1391,7 +1391,7 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) if (m_si->pLogEnd) Log_StreamInEvent(m_si->pLog, FALSE); else - SendMessage(m_hwnd, GC_CONTROL_MSG, WINDOW_CLEARLOG, 0); + ClearLog(); break; case DM_UPDATETABCONTROL: @@ -1541,60 +1541,6 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) SendMessage(m_hwnd, DM_UPDATETITLEBAR, 0, 0); break; - case GC_CONTROL_MSG: - switch (wParam) { - case SESSION_OFFLINE: - SendMessage(m_hwnd, GC_UPDATESTATUSBAR, 0, 0); - SendMessage(m_hwnd, GC_UPDATENICKLIST, 0, 0); - return TRUE; - - case SESSION_ONLINE: - SendMessage(m_hwnd, GC_UPDATESTATUSBAR, 0, 0); - return TRUE; - - case WINDOW_HIDDEN: - SendMessage(m_hwnd, GC_CLOSEWINDOW, 0, 0); - return TRUE; - - case WINDOW_CLEARLOG: - m_log.SetText(L""); - return TRUE; - - case SESSION_TERMINATE: - if (pcli->pfnGetEvent(m_hContact, 0)) - pcli->pfnRemoveEvent(m_hContact, GC_FAKE_EVENT); - m_si->wState &= ~STATE_TALK; - db_set_w(m_hContact, m_si->pszModule, "ApparentMode", 0); - SendMessage(m_hwnd, GC_CLOSEWINDOW, 0, 0); - return TRUE; - - case WINDOW_MINIMIZE: - ShowWindow(m_hwnd, SW_MINIMIZE); - goto LABEL_SHOWWINDOW; - - case WINDOW_MAXIMIZE: - ShowWindow(m_hwnd, SW_MAXIMIZE); - goto LABEL_SHOWWINDOW; - - case SESSION_INITDONE: - if (db_get_b(0, CHAT_MODULE, "PopupOnJoin", 0) != 0) - return TRUE; - // fall through - case WINDOW_VISIBLE: - if (IsIconic(m_hwnd)) - ShowWindow(m_hwnd, SW_NORMAL); - LABEL_SHOWWINDOW: - SendMessage(m_hwnd, WM_SIZE, 0, 0); - SendMessage(m_hwnd, GC_REDRAWLOG, 0, 0); - SendMessage(m_hwnd, GC_UPDATENICKLIST, 0, 0); - SendMessage(m_hwnd, GC_UPDATESTATUSBAR, 0, 0); - ShowWindow(m_hwnd, SW_SHOW); - SendMessage(m_hwnd, WM_SIZE, 0, 0); - SetForegroundWindow(m_hwnd); - return TRUE; - } - break; - case GC_CHANGEFILTERFLAG: m_iLogFilterFlags = lParam; break; @@ -1634,12 +1580,12 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) if (LOWORD(wParam) != WA_ACTIVE) break; - //fall through + // fall through case WM_MOUSEACTIVATE: if (uMsg != WM_ACTIVATE) SetFocus(m_message.GetHwnd()); - pci->SetActiveSession(m_si->ptszID, m_si->pszModule); + pci->SetActiveSession(m_si); if (db_get_w(m_hContact, m_si->pszModule, "ApparentMode", 0) != 0) db_set_w(m_hContact, m_si->pszModule, "ApparentMode", 0); diff --git a/plugins/Scriver/src/msgdialog.cpp b/plugins/Scriver/src/msgdialog.cpp index 037f1eef6d..e131d282ca 100644 --- a/plugins/Scriver/src/msgdialog.cpp +++ b/plugins/Scriver/src/msgdialog.cpp @@ -1239,7 +1239,7 @@ INT_PTR CSrmmWindow::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) pf2.dwMask = PFM_OFFSET; pf2.dxOffset = (g_dat.flags & SMF_INDENTTEXT) ? g_dat.indentSize * 1440 / g_dat.logPixelSX : 0; - SetDlgItemText(m_hwnd, IDC_LOG, L""); + ClearLog(); m_log.SendMsg(EM_SETPARAFORMAT, 0, (LPARAM)&pf2); m_log.SendMsg(EM_SETLANGOPTIONS, 0, (LPARAM)m_log.SendMsg(EM_GETLANGOPTIONS, 0, 0) & ~(IMF_AUTOKEYBOARD | IMF_AUTOFONTSIZEADJUST)); @@ -1523,7 +1523,7 @@ INT_PTR CSrmmWindow::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) CallService(MS_IEVIEW_EVENT, 0, (LPARAM)&evt); } - SetDlgItemText(m_hwnd, IDC_LOG, L""); + ClearLog(); m_hDbEventFirst = 0; m_lastEventType = -1; break; diff --git a/plugins/Scriver/src/msglog.cpp b/plugins/Scriver/src/msglog.cpp index 71fbab8539..cd340a7dc2 100644 --- a/plugins/Scriver/src/msglog.cpp +++ b/plugins/Scriver/src/msglog.cpp @@ -796,7 +796,7 @@ void CSrmmWindow::StreamInEvents(MEVENT hDbEventFirst, int count, int fAppend) } else { m_log.SendMsg(WM_SETREDRAW, FALSE, 0); - m_log.SetText(L""); + ClearLog(); sel.cpMin = 0; sel.cpMax = GetRichTextLength(m_log.GetHwnd(), 1200, FALSE); m_log.SendMsg(EM_EXSETSEL, 0, (LPARAM)&sel); diff --git a/plugins/Scriver/src/msgs.cpp b/plugins/Scriver/src/msgs.cpp index ba4bd65404..fa0f0a6265 100644 --- a/plugins/Scriver/src/msgs.cpp +++ b/plugins/Scriver/src/msgs.cpp @@ -366,22 +366,6 @@ CScriverWindow::CScriverWindow(int iDialog, SESSION_INFO *si) m_autoClose = CLOSE_ON_CANCEL; } -INT_PTR CScriverWindow::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - if (uMsg == WM_COMMAND) { - if (!lParam && Clist_MenuProcessCommand(LOWORD(wParam), MPCF_CONTACTMENU, m_hContact)) - return 0; - - if (HIWORD(wParam) == BN_CLICKED) - if (LOWORD(wParam) >= MIN_CBUTTONID && LOWORD(wParam) <= MAX_CBUTTONID) { - Srmm_ClickToolbarIcon(m_hContact, LOWORD(wParam), GetDlgItem(m_hwnd, LOWORD(wParam)), 0); - return 0; - } - } - - return CSrmmBaseDialog::DlgProc(uMsg, wParam, lParam); -} - ///////////////////////////////////////////////////////////////////////////////////////// // status icons processing diff --git a/plugins/Scriver/src/msgs.h b/plugins/Scriver/src/msgs.h index 03ae1eee12..9bde19bcec 100644 --- a/plugins/Scriver/src/msgs.h +++ b/plugins/Scriver/src/msgs.h @@ -90,8 +90,6 @@ class CScriverWindow : public CSrmmBaseDialog protected: CScriverWindow(int iDialog, SESSION_INFO* = nullptr); - virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override; - public: ParentWindowData *m_pParent; int m_minLogBoxHeight, m_minEditBoxHeight; diff --git a/plugins/TabSRMM/src/chat_log.cpp b/plugins/TabSRMM/src/chat_log.cpp index 26884a7ed8..bdcdadf887 100644 --- a/plugins/TabSRMM/src/chat_log.cpp +++ b/plugins/TabSRMM/src/chat_log.cpp @@ -633,8 +633,6 @@ static void AddEventToBuffer(CMStringA &str, LOGSTREAMDATA *streamData) char* Log_CreateRtfHeader(MODULEINFO *mi) { - int i = 0; - // get the number of pixels per logical inch if (pci->logPixelSY == 0) { HDC hdc = GetDC(nullptr); @@ -647,19 +645,19 @@ char* Log_CreateRtfHeader(MODULEINFO *mi) // font table CMStringA str("{\\rtf1\\ansi\\deff0{\\fonttbl"); - for (i = 0; i < OPTIONS_FONTCOUNT; i++) + for (int i = 0; i < OPTIONS_FONTCOUNT; i++) str.AppendFormat("{\\f%u\\fnil\\fcharset%u%S;}", i, pci->aFonts[i].lf.lfCharSet, pci->aFonts[i].lf.lfFaceName); // colour table str.Append("}{\\colortbl ;"); - for (i = 0; i < OPTIONS_FONTCOUNT; i++) + for (int i = 0; i < OPTIONS_FONTCOUNT; i++) str.AppendFormat("\\red%u\\green%u\\blue%u;", GetRValue(pci->aFonts[i].color), GetGValue(pci->aFonts[i].color), GetBValue(pci->aFonts[i].color)); - for (i = 0; i < mi->nColorCount; i++) + for (int i = 0; i < mi->nColorCount; i++) str.AppendFormat("\\red%u\\green%u\\blue%u;", GetRValue(mi->crColors[i]), GetGValue(mi->crColors[i]), GetBValue(mi->crColors[i])); - for (i = 0; i < STATUSICONCOUNT; i++) + for (int i = 0; i < STATUSICONCOUNT; i++) str.AppendFormat("\\red%u\\green%u\\blue%u;", GetRValue(g_Settings.nickColors[i]), GetGValue(g_Settings.nickColors[i]), GetBValue(g_Settings.nickColors[i])); // new paragraph @@ -839,11 +837,9 @@ void CChatRoomDlg::StreamInEvents(LOGINFO *lin, SESSION_INFO *si, bool bRedraw) if (m_hwnd == 0 || lin == 0 || si == 0) return; - HWND hwndRich = GetDlgItem(m_hwnd, IDC_LOG); - LOGSTREAMDATA streamData; memset(&streamData, 0, sizeof(streamData)); - streamData.hwnd = hwndRich; + streamData.hwnd = m_log.GetHwnd(); streamData.si = si; streamData.lin = lin; streamData.bStripFormat = FALSE; @@ -854,24 +850,24 @@ void CChatRoomDlg::StreamInEvents(LOGINFO *lin, SESSION_INFO *si, bool bRedraw) bool bFlag = false, fDoReplace; - EDITSTREAM stream = { 0 }; + EDITSTREAM stream = {}; stream.pfnCallback = Srmm_LogStreamCallback; stream.dwCookie = (DWORD_PTR)& streamData; - SCROLLINFO scroll = { 0 }; + SCROLLINFO scroll = {}; scroll.cbSize = sizeof(SCROLLINFO); scroll.fMask = SIF_RANGE | SIF_POS | SIF_PAGE; GetScrollInfo(GetDlgItem(m_hwnd, IDC_LOG), SB_VERT, &scroll); - SendMessage(hwndRich, EM_GETSCROLLPOS, 0, (LPARAM)&point); + m_log.SendMsg(EM_GETSCROLLPOS, 0, (LPARAM)&point); // do not scroll to bottom if there is a selection - SendMessage(hwndRich, EM_EXGETSEL, 0, (LPARAM)&oldsel); + m_log.SendMsg(EM_EXGETSEL, 0, (LPARAM)&oldsel); if (oldsel.cpMax != oldsel.cpMin) - SendMessage(hwndRich, WM_SETREDRAW, FALSE, 0); + m_log.SendMsg(WM_SETREDRAW, FALSE, 0); // set the insertion point at the bottom - sel.cpMin = sel.cpMax = GetRichTextLength(hwndRich); - SendMessage(hwndRich, EM_EXSETSEL, 0, (LPARAM)&sel); + sel.cpMin = sel.cpMax = GetRichTextLength(m_log.GetHwnd()); + m_log.SendMsg(EM_EXSETSEL, 0, (LPARAM)&sel); // fix for the indent... must be a M$ bug if (sel.cpMax == 0) @@ -886,14 +882,14 @@ void CChatRoomDlg::StreamInEvents(LOGINFO *lin, SESSION_INFO *si, bool bRedraw) pci->logPixelSY = GetDeviceCaps(hdc, LOGPIXELSY); pci->logPixelSX = GetDeviceCaps(hdc, LOGPIXELSX); ReleaseDC(nullptr, hdc); - SendMessage(hwndRich, WM_SETREDRAW, FALSE, 0); + m_log.SendMsg(WM_SETREDRAW, FALSE, 0); bFlag = true; } // stream in the event(s) streamData.lin = lin; streamData.bRedraw = bRedraw; - SendMessage(hwndRich, EM_STREAMIN, wp, (LPARAM)&stream); + m_log.SendMsg(EM_STREAMIN, wp, (LPARAM)&stream); // for new added events, only replace in message or action events. // no need to replace smileys or math formulas elsewhere @@ -912,29 +908,28 @@ void CChatRoomDlg::StreamInEvents(LOGINFO *lin, SESSION_INFO *si, bool bRedraw) fi.chrg.cpMax = -1; fi.lpstrText = L"~~++#"; - while (SendMessage(hwndRich, EM_FINDTEXTEX, FR_DOWN, (LPARAM)&fi) > -1) { + while (m_log.SendMsg(EM_FINDTEXTEX, FR_DOWN, (LPARAM)&fi) > -1) { fi2.chrg.cpMin = fi.chrgText.cpMin; fi2.chrg.cpMax = -1; - if (SendMessage(hwndRich, EM_FINDTEXTEX, FR_DOWN, (LPARAM)&fi2) > -1) { - - SendMessage(hwndRich, EM_EXSETSEL, 0, (LPARAM)&fi.chrgText); - SendMessage(hwndRich, EM_REPLACESEL, TRUE, (LPARAM)L""); + if (m_log.SendMsg(EM_FINDTEXTEX, FR_DOWN, (LPARAM)&fi2) > -1) { + m_log.SendMsg(EM_EXSETSEL, 0, (LPARAM)&fi.chrgText); + m_log.SendMsg(EM_REPLACESEL, TRUE, (LPARAM)L""); fi2.chrgText.cpMin -= fi.chrgText.cpMax - fi.chrgText.cpMin; fi2.chrgText.cpMax -= fi.chrgText.cpMax - fi.chrgText.cpMin; - SendMessage(hwndRich, EM_EXSETSEL, 0, (LPARAM)&fi2.chrgText); - SendMessage(hwndRich, EM_REPLACESEL, TRUE, (LPARAM)L""); + m_log.SendMsg(EM_EXSETSEL, 0, (LPARAM)&fi2.chrgText); + m_log.SendMsg(EM_REPLACESEL, TRUE, (LPARAM)L""); fi2.chrgText.cpMax = fi2.chrgText.cpMin; fi2.chrgText.cpMin = fi.chrgText.cpMin; - SendMessage(hwndRich, EM_EXSETSEL, 0, (LPARAM)&fi2.chrgText); + m_log.SendMsg(EM_EXSETSEL, 0, (LPARAM)&fi2.chrgText); cf2.dwMask = CFM_PROTECTED; cf2.dwEffects = CFE_PROTECTED; - SendMessage(hwndRich, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf2); + m_log.SendMsg(EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf2); } fi.chrg.cpMin = fi.chrgText.cpMax; } - SendMessage(hwndRich, EM_SETSEL, -1, -1); + m_log.SendMsg(EM_SETSEL, -1, -1); } // run smileyadd @@ -945,7 +940,7 @@ void CChatRoomDlg::StreamInEvents(LOGINFO *lin, SESSION_INFO *si, bool bRedraw) newsel.cpMin = 0; SMADD_RICHEDIT3 sm = { sizeof(sm) }; - sm.hwndRichEditControl = hwndRich; + sm.hwndRichEditControl = m_log.GetHwnd(); sm.Protocolname = si->pszModule; sm.rangeToReplace = bRedraw ? nullptr : &newsel; sm.disableRedraw = TRUE; @@ -963,34 +958,34 @@ void CChatRoomDlg::StreamInEvents(LOGINFO *lin, SESSION_INFO *si, bool bRedraw) fi.lpstrText = szPattern; fi.chrg.cpMin = 0; fi.chrg.cpMax = -1; - if (SendMessage(hwndRich, EM_FINDTEXTEX, FR_DOWN, (LPARAM)&fi) != 0) { + if (m_log.SendMsg(EM_FINDTEXTEX, FR_DOWN, (LPARAM)&fi) != 0) { CHARRANGE rng; rng.cpMin = 0; rng.cpMax = 20; - SendMessage(hwndRich, EM_SETSEL, 0, fi.chrgText.cpMax + 1); - SendMessage(hwndRich, EM_REPLACESEL, TRUE, (LPARAM)L""); + m_log.SendMsg(EM_SETSEL, 0, fi.chrgText.cpMax + 1); + m_log.SendMsg(EM_REPLACESEL, TRUE, (LPARAM)L""); } si->bTrimmed = false; } // scroll log to bottom if the log was previously scrolled to bottom, else restore old position if ((bRedraw || (UINT)scroll.nPos >= (UINT)scroll.nMax - scroll.nPage - 5 || scroll.nMax - scroll.nMin - scroll.nPage < 50)) - SendMessage(GetParent(hwndRich), GC_SCROLLTOBOTTOM, 0, 0); + SendMessage(GetParent(m_log.GetHwnd()), GC_SCROLLTOBOTTOM, 0, 0); else - SendMessage(hwndRich, EM_SETSCROLLPOS, 0, (LPARAM)&point); + m_log.SendMsg(EM_SETSCROLLPOS, 0, (LPARAM)&point); // do we need to restore the selection if (oldsel.cpMax != oldsel.cpMin) { - SendMessage(hwndRich, EM_EXSETSEL, 0, (LPARAM)&oldsel); - SendMessage(hwndRich, WM_SETREDRAW, TRUE, 0); - InvalidateRect(hwndRich, nullptr, TRUE); + m_log.SendMsg(EM_EXSETSEL, 0, (LPARAM)&oldsel); + m_log.SendMsg(WM_SETREDRAW, TRUE, 0); + InvalidateRect(m_log.GetHwnd(), nullptr, TRUE); } // need to invalidate the window if (bFlag) { - sel.cpMin = sel.cpMax = GetRichTextLength(hwndRich); - SendMessage(hwndRich, EM_EXSETSEL, 0, (LPARAM)&sel); - SendMessage(hwndRich, WM_SETREDRAW, TRUE, 0); - InvalidateRect(hwndRich, nullptr, TRUE); + sel.cpMin = sel.cpMax = GetRichTextLength(m_log.GetHwnd()); + m_log.SendMsg(EM_EXSETSEL, 0, (LPARAM)&sel); + m_log.SendMsg(WM_SETREDRAW, TRUE, 0); + InvalidateRect(m_log.GetHwnd(), nullptr, TRUE); } } diff --git a/plugins/TabSRMM/src/chat_window.cpp b/plugins/TabSRMM/src/chat_window.cpp index 3869504ee2..127a7b4d60 100644 --- a/plugins/TabSRMM/src/chat_window.cpp +++ b/plugins/TabSRMM/src/chat_window.cpp @@ -183,12 +183,12 @@ void CChatRoomDlg::UpdateWindowState(UINT msg) m_pWnd->setOverlayIcon(0, true); } - if (m_pContainer->hwndSaved == m_hwnd || m_bWasDeleted) + if (m_pContainer->hwndSaved == m_hwnd) return; m_pContainer->hwndSaved = m_hwnd; - pci->SetActiveSession(m_si->ptszID, m_si->pszModule); + pci->SetActiveSession(m_si); m_hTabIcon = m_hTabStatusIcon; if (m_iTabID >= 0) { @@ -1552,16 +1552,16 @@ CChatRoomDlg::CChatRoomDlg(SESSION_INFO *si) m_list.OnDblClick = Callback(this, &CChatRoomDlg::OnDblClick_List); } -CThumbBase* CChatRoomDlg::CreateThumb(CProxyWindow *pProxy) const +CThumbBase* CChatRoomDlg::tabCreateThumb(CProxyWindow *pProxy) const { return new CThumbMUC(pProxy, m_si); } -void CChatRoomDlg::ClearLog() +void CChatRoomDlg::tabClearLog() { SESSION_INFO *s = pci->SM_FindSession(m_si->ptszID, m_si->pszModule); if (s) { - m_log.SetText(L""); + ClearLog(); pci->LM_RemoveAll(&s->pLog, &s->pLogEnd); s->iEventCount = 0; s->LastTime = 0; @@ -1998,9 +1998,8 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) case DM_UPDATETITLE: case GC_UPDATETITLE: - if (!m_bWasDeleted) { - m_wStatus = m_si->wStatus; - + m_wStatus = m_si->wStatus; + { const wchar_t *szNick = m_cache->getNick(); if (mir_wstrlen(szNick) > 0) { if (M.GetByte("cuttitle", 0)) @@ -2058,9 +2057,6 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) break; case GC_UPDATESTATUSBAR: - if (m_bWasDeleted) - return 0; - if (m_pContainer->hwndActive != m_hwnd || m_pContainer->hwndStatus == 0 || CMimAPI::m_shutDown || m_wszStatusBar[0]) break; @@ -2170,7 +2166,7 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) } else StreamInEvents(m_si->pLogEnd, m_si, TRUE); } - else SendMessage(m_hwnd, GC_CONTROL_MSG, WINDOW_CLEARLOG, 0); + else ClearLog(); break; case GC_REDRAWLOG2: @@ -2197,7 +2193,7 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) if (m_si->pLogEnd) StreamInEvents(m_si->pLog, m_si, FALSE); else - SendMessage(m_hwnd, GC_CONTROL_MSG, WINDOW_CLEARLOG, 0); + ClearLog(); break; case DM_TYPING: @@ -2350,107 +2346,49 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) } break; - case GC_CONTROL_MSG: - switch (wParam) { - case SESSION_OFFLINE: - SendMessage(m_hwnd, GC_UPDATESTATUSBAR, 0, 0); - SendMessage(m_si->pDlg->GetHwnd(), GC_UPDATENICKLIST, 0, 0); - return TRUE; - - case SESSION_ONLINE: - SendMessage(m_hwnd, GC_UPDATESTATUSBAR, 0, 0); - return TRUE; - - case WINDOW_HIDDEN: - SendMessage(m_hwnd, GC_CLOSEWINDOW, 0, 1); - return TRUE; - - case WINDOW_CLEARLOG: - SetDlgItemText(m_hwnd, IDC_LOG, L""); - return TRUE; - - case SESSION_TERMINATE: - if (pcli->pfnGetEvent(m_si->hContact, 0)) - pcli->pfnRemoveEvent(m_si->hContact, GC_FAKE_EVENT); - - m_si->wState &= ~STATE_TALK; - m_bWasDeleted = true; - db_set_w(m_si->hContact, m_si->pszModule, "ApparentMode", 0); - SendMessage(m_hwnd, GC_CLOSEWINDOW, 0, lParam == 2 ? lParam : 1); - return TRUE; + case DM_SPLITTERMOVED: + RECT rcLog; + GetWindowRect(m_log.GetHwnd(), &rcLog); - case WINDOW_MINIMIZE: - ShowWindow(m_hwnd, SW_MINIMIZE); -LABEL_SHOWWINDOW: + if ((HWND)lParam == GetDlgItem(m_hwnd, IDC_SPLITTERX)) { + GetClientRect(m_hwnd, &rc); + pt.x = wParam, pt.y = 0; + ScreenToClient(m_hwnd, &pt); + + int iSplitterX = rc.right - pt.x + 1; + if (iSplitterX < 35) + iSplitterX = 35; + if (iSplitterX > rc.right - rc.left - 35) + iSplitterX = rc.right - rc.left - 35; + m_pContainer->settings->iSplitterX = iSplitterX; SendMessage(m_hwnd, WM_SIZE, 0, 0); - SendMessage(m_hwnd, GC_REDRAWLOG, 0, 0); - SendMessage(m_hwnd, GC_UPDATENICKLIST, 0, 0); - SendMessage(m_hwnd, GC_UPDATESTATUSBAR, 0, 0); - ShowWindow(m_hwnd, SW_SHOW); + } + else if ((HWND)lParam == GetDlgItem(m_hwnd, IDC_SPLITTERY) || lParam == -1) { + GetClientRect(m_hwnd, &rc); + rc.top += (m_pPanel.isActive() ? m_pPanel.getHeight() + 40 : 30); + pt.x = 0, pt.y = wParam; + ScreenToClient(m_hwnd, &pt); + + m_iSplitterY = rc.bottom - pt.y + DPISCALEY_S(1); + if (m_iSplitterY < DPISCALEY_S(23)) + m_iSplitterY = DPISCALEY_S(23); + if (m_iSplitterY > rc.bottom - rc.top - DPISCALEY_S(40)) + m_iSplitterY = rc.bottom - rc.top - DPISCALEY_S(40); + m_pContainer->settings->iSplitterY = m_iSplitterY; + UpdateToolbarBG(); SendMessage(m_hwnd, WM_SIZE, 0, 0); - SetForegroundWindow(m_hwnd); - return TRUE; - - case WINDOW_MAXIMIZE: - ShowWindow(m_hwnd, SW_MAXIMIZE); - goto LABEL_SHOWWINDOW; - - case SESSION_INITDONE: - if (M.GetByte(CHAT_MODULE, "PopupOnJoin", 0) != 0) - return TRUE; - - // fall through - case WINDOW_VISIBLE: - if (IsIconic(m_hwnd)) - ShowWindow(m_hwnd, SW_NORMAL); - goto LABEL_SHOWWINDOW; } - break; - - case DM_SPLITTERMOVED: - RECT rcLog; - { - GetWindowRect(m_log.GetHwnd(), &rcLog); - if ((HWND)lParam == GetDlgItem(m_hwnd, IDC_SPLITTERX)) { - GetClientRect(m_hwnd, &rc); - pt.x = wParam, pt.y = 0; - ScreenToClient(m_hwnd, &pt); - - int iSplitterX = rc.right - pt.x + 1; - if (iSplitterX < 35) - iSplitterX = 35; - if (iSplitterX > rc.right - rc.left - 35) - iSplitterX = rc.right - rc.left - 35; - m_pContainer->settings->iSplitterX = iSplitterX; - SendMessage(m_hwnd, WM_SIZE, 0, 0); - } - else if ((HWND)lParam == GetDlgItem(m_hwnd, IDC_SPLITTERY) || lParam == -1) { - GetClientRect(m_hwnd, &rc); - rc.top += (m_pPanel.isActive() ? m_pPanel.getHeight() + 40 : 30); - pt.x = 0, pt.y = wParam; - ScreenToClient(m_hwnd, &pt); - - m_iSplitterY = rc.bottom - pt.y + DPISCALEY_S(1); - if (m_iSplitterY < DPISCALEY_S(23)) - m_iSplitterY = DPISCALEY_S(23); - if (m_iSplitterY > rc.bottom - rc.top - DPISCALEY_S(40)) - m_iSplitterY = rc.bottom - rc.top - DPISCALEY_S(40); - m_pContainer->settings->iSplitterY = m_iSplitterY; - UpdateToolbarBG(); - SendMessage(m_hwnd, WM_SIZE, 0, 0); - } - else if ((HWND)lParam == GetDlgItem(m_hwnd, IDC_PANELSPLITTER)) { - pt.x = 0, pt.y = wParam; - ScreenToClient(m_hwnd, &pt); - GetClientRect(m_log.GetHwnd(), &rc); - if ((pt.y + 2 >= MIN_PANELHEIGHT + 2) && (pt.y + 2 < 100) && (pt.y + 2 < rc.bottom - 30)) - m_pPanel.setHeight(pt.y + 2); - RedrawWindow(m_hwnd, nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE); - if (M.isAero()) - InvalidateRect(m_hwndParent, nullptr, FALSE); - SendMessage(m_hwnd, WM_SIZE, DM_SPLITTERMOVED, 0); - break; - } + else if ((HWND)lParam == GetDlgItem(m_hwnd, IDC_PANELSPLITTER)) { + pt.x = 0, pt.y = wParam; + ScreenToClient(m_hwnd, &pt); + GetClientRect(m_log.GetHwnd(), &rc); + if ((pt.y + 2 >= MIN_PANELHEIGHT + 2) && (pt.y + 2 < 100) && (pt.y + 2 < rc.bottom - 30)) + m_pPanel.setHeight(pt.y + 2); + RedrawWindow(m_hwnd, nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE); + if (M.isAero()) + InvalidateRect(m_hwndParent, nullptr, FALSE); + SendMessage(m_hwnd, WM_SIZE, DM_SPLITTERMOVED, 0); + break; } break; @@ -2643,7 +2581,7 @@ LABEL_SHOWWINDOW: break; case ID_CLEARLOG: - ClearLog(); + tabClearLog(); break; case ID_SEARCH_GOOGLE: @@ -2820,11 +2758,6 @@ LABEL_SHOWWINDOW: break; case WM_COMMAND: - if (LOWORD(wParam) >= MIN_CBUTTONID && LOWORD(wParam) <= MAX_CBUTTONID){ - Srmm_ClickToolbarIcon(m_hContact, LOWORD(wParam), GetDlgItem(m_hwnd, LOWORD(wParam)), 0); - break; - } - switch (LOWORD(wParam)) { case IDC_TOGGLESIDEBAR: SendMessage(m_pContainer->hwnd, WM_COMMAND, IDC_TOGGLESIDEBAR, 0); diff --git a/plugins/TabSRMM/src/generic_msghandlers.cpp b/plugins/TabSRMM/src/generic_msghandlers.cpp index 1f81e18ac1..88cc78091c 100644 --- a/plugins/TabSRMM/src/generic_msghandlers.cpp +++ b/plugins/TabSRMM/src/generic_msghandlers.cpp @@ -151,7 +151,7 @@ bool CTabBaseDlg::DM_GenericHotkeysCheck(MSG *message) return true; case TABSRMM_HK_CLEARLOG: - ClearLog(); + tabClearLog(); return true; case TABSRMM_HK_TOGGLESIDEBAR: @@ -479,7 +479,7 @@ LRESULT CTabBaseDlg::DM_MsgWindowCmdHandler(UINT cmd, WPARAM wParam, LPARAM lPar break; case IDM_CLEAR: - ClearLog(); + tabClearLog(); break; case IDC_PROTOCOL: @@ -612,7 +612,7 @@ void CTabBaseDlg::DM_InitRichEdit() pf2.dxOffset = m_pContainer->theme.left_indent + 30; if (!fIsChat) { - m_log.SetText(L""); + ClearLog(); m_log.SendMsg(EM_SETPARAFORMAT, 0, (LPARAM)&pf2); m_log.SendMsg(EM_SETLANGOPTIONS, 0, (LPARAM)SendDlgItemMessage(m_hwnd, IDC_LOG, EM_GETLANGOPTIONS, 0, 0) & ~IMF_AUTOKEYBOARD); // set the scrollbars etc to RTL/LTR (only for manual RTL mode) diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp index 28231fa2b8..facf8f9345 100644 --- a/plugins/TabSRMM/src/msgdialog.cpp +++ b/plugins/TabSRMM/src/msgdialog.cpp @@ -154,7 +154,7 @@ static void ShowPopupMenu(CTabBaseDlg *dat, int idFrom, HWND hwndFrom, POINT pt) SendMessage(hwndFrom, EM_EXSETSEL, 0, (LPARAM)&all); break; case IDM_CLEAR: - dat->ClearLog(); + dat->tabClearLog(); break; case ID_LOG_FREEZELOG: SendDlgItemMessage(hwndDlg, IDC_LOG, WM_KEYDOWN, VK_F12, 0); @@ -921,7 +921,7 @@ CSrmmWindow::CSrmmWindow() { } -void CSrmmWindow::ClearLog() +void CSrmmWindow::tabClearLog() { if (m_hwndIEView || m_hwndHPP) { IEVIEWEVENT event; @@ -942,7 +942,7 @@ void CSrmmWindow::ClearLog() m_hDbEventFirst = 0; } -CThumbBase* CSrmmWindow::CreateThumb(CProxyWindow *pProxy) const +CThumbBase* CSrmmWindow::tabCreateThumb(CProxyWindow *pProxy) const { return new CThumbIM(pProxy); } @@ -2512,15 +2512,6 @@ INT_PTR CSrmmWindow::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) break; case WM_COMMAND: - if (!this) - break; - - // custom button handling - if (LOWORD(wParam) >= MIN_CBUTTONID && LOWORD(wParam) <= MAX_CBUTTONID) { - Srmm_ClickToolbarIcon(m_hContact, LOWORD(wParam), GetDlgItem(m_hwnd, LOWORD(wParam)), 0); - break; - } - switch (LOWORD(wParam)) { case IDOK: if (m_bEditNotesActive) { diff --git a/plugins/TabSRMM/src/msgs.h b/plugins/TabSRMM/src/msgs.h index 879b9bd1eb..64e9779e0c 100644 --- a/plugins/TabSRMM/src/msgs.h +++ b/plugins/TabSRMM/src/msgs.h @@ -358,8 +358,8 @@ public: virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override; - virtual CThumbBase* CreateThumb(CProxyWindow*) const = 0; - virtual void ClearLog() = 0; + virtual CThumbBase* tabCreateThumb(CProxyWindow*) const = 0; + virtual void tabClearLog() = 0; static LONG_PTR CALLBACK StatusBarSubclassProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); @@ -433,8 +433,8 @@ public: class CSrmmWindow : public CTabBaseDlg { - virtual CThumbBase* CreateThumb(CProxyWindow *pProxy) const override; - virtual void ClearLog() override; + virtual CThumbBase* tabCreateThumb(CProxyWindow *pProxy) const override; + virtual void tabClearLog() override; void MsgWindowUpdateState(UINT msg); void ReplayQueue(); @@ -461,7 +461,6 @@ public: class CChatRoomDlg : public CTabBaseDlg { HWND m_hwndFilter; - bool m_bWasDeleted; CCtrlButton m_btnFilter, m_btnHistory, m_btnChannelMgr, m_btnNickList, m_btnOk; CCtrlButton m_btnBold, m_btnItalic, m_btnUnderline, m_btnColor, m_btnBkColor; CCtrlListBox m_list; @@ -470,8 +469,8 @@ class CChatRoomDlg : public CTabBaseDlg static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); static INT_PTR CALLBACK FilterWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); - virtual CThumbBase* CreateThumb(CProxyWindow *pProxy) const override; - virtual void ClearLog() override; + virtual CThumbBase* tabCreateThumb(CProxyWindow *pProxy) const override; + virtual void tabClearLog() override; public: int m_iSearchItem; diff --git a/plugins/TabSRMM/src/taskbar.cpp b/plugins/TabSRMM/src/taskbar.cpp index 4d3f846610..f206631744 100644 --- a/plugins/TabSRMM/src/taskbar.cpp +++ b/plugins/TabSRMM/src/taskbar.cpp @@ -293,7 +293,7 @@ void CProxyWindow::sendThumb(LONG width, LONG height) if (0 == m_thumb) { m_width = width; m_height = height; - m_thumb = m_dat->CreateThumb(this); + m_thumb = m_dat->tabCreateThumb(this); } else if (width != m_width || height != m_height || !m_thumb->isValid()) { m_width = width; -- cgit v1.2.3