From 7f513673b523ecfbf6ded0a2d0e5cdf5496bd6b0 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 3 Apr 2017 23:52:09 +0300 Subject: - SRMM window list management moved to the base class; - fixes #791 --- plugins/Scriver/src/chat_window.cpp | 2 -- plugins/Scriver/src/msgdialog.cpp | 8 +------- plugins/Scriver/src/msglog.cpp | 2 +- plugins/Scriver/src/msgs.cpp | 20 +++++++++++--------- plugins/Scriver/src/msgs.h | 4 ++-- plugins/TabSRMM/src/chat_window.cpp | 2 -- plugins/TabSRMM/src/mim.cpp | 10 ---------- plugins/TabSRMM/src/mim.h | 2 -- plugins/TabSRMM/src/msgdialog.cpp | 1 - plugins/TabSRMM/src/msgs.cpp | 2 -- 10 files changed, 15 insertions(+), 38 deletions(-) (limited to 'plugins') diff --git a/plugins/Scriver/src/chat_window.cpp b/plugins/Scriver/src/chat_window.cpp index 288fbdf6ff..4efe867148 100644 --- a/plugins/Scriver/src/chat_window.cpp +++ b/plugins/Scriver/src/chat_window.cpp @@ -213,7 +213,6 @@ void CChatRoomDlg::OnInitDialog() NotifyEvent(MSG_WINDOW_EVT_OPENING); - SetWindowLongPtr(m_hwnd, GWLP_USERDATA, (LONG_PTR)this); m_pParent = (ParentWindowData *)GetWindowLongPtr(m_hwndParent, GWLP_USERDATA); Srmm_CreateToolbarIcons(m_hwnd, BBBF_ISCHATBUTTON); @@ -273,7 +272,6 @@ void CChatRoomDlg::OnDestroy() NotifyEvent(MSG_WINDOW_EVT_CLOSING); m_si->pDlg = nullptr; - SetWindowLongPtr(m_hwnd, GWLP_USERDATA, 0); SendMessage(m_hwndParent, CM_REMOVECHILD, 0, (LPARAM)m_hwnd); if (m_hwndIeview != nullptr) { diff --git a/plugins/Scriver/src/msgdialog.cpp b/plugins/Scriver/src/msgdialog.cpp index 03099767dd..1dce87450c 100644 --- a/plugins/Scriver/src/msgdialog.cpp +++ b/plugins/Scriver/src/msgdialog.cpp @@ -170,7 +170,7 @@ static INT_PTR CALLBACK ConfirmSendAllDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa ///////////////////////////////////////////////////////////////////////////////////////// -CSrmmWindow::CSrmmWindow(MCONTACT hContact, bool bIncoming, const char *szInitialText, bool bIsUnicode) +CSrmmWindow::CSrmmWindow(MCONTACT hContact, bool bIncoming) : CScriverWindow(IDD_MSG), m_bIncoming(bIncoming), m_splitter(this, IDC_SPLITTERY), @@ -184,7 +184,6 @@ CSrmmWindow::CSrmmWindow(MCONTACT hContact, bool bIncoming, const char *szInitia m_hContact = hContact; m_hwndParent = GetParentWindow(hContact, FALSE); - m_wszInitialText = (bIsUnicode) ? mir_wstrdup((wchar_t*)szInitialText) : mir_a2u(szInitialText); m_btnOk.OnClick = Callback(this, &CSrmmWindow::onClick_Ok); m_btnAdd.OnClick = Callback(this, &CSrmmWindow::onClick_Add); @@ -201,9 +200,6 @@ void CSrmmWindow::OnInitDialog() { CSuper::OnInitDialog(); - SetWindowLongPtr(m_hwnd, GWLP_USERDATA, (LONG_PTR)this); - WindowList_Add(pci->hWindowList, m_hwnd, m_hContact); - NotifyEvent(MSG_WINDOW_EVT_OPENING); m_pParent = (ParentWindowData *)GetWindowLongPtr(m_hwndParent, GWLP_USERDATA); @@ -424,7 +420,6 @@ void CSrmmWindow::OnDestroy() } tcmdlist_free(cmdList); - WindowList_Remove(pci->hWindowList, m_hwnd); HFONT hFont = (HFONT)m_message.SendMsg(WM_GETFONT, 0, 0); if (hFont != nullptr && hFont != (HFONT)m_btnOk.SendMsg(WM_GETFONT, 0, 0)) @@ -435,7 +430,6 @@ void CSrmmWindow::OnDestroy() if (db_get_b(m_hContact, "CList", "NotOnList", 0)) db_delete_contact(m_hContact); - SetWindowLongPtr(m_hwnd, GWLP_USERDATA, 0); SendMessage(m_hwndParent, CM_REMOVECHILD, 0, (LPARAM)m_hwnd); if (m_hwndIeview != nullptr) { IEVIEWWINDOW ieWindow = { sizeof(ieWindow) }; diff --git a/plugins/Scriver/src/msglog.cpp b/plugins/Scriver/src/msglog.cpp index e9919046ce..0f984c7e2d 100644 --- a/plugins/Scriver/src/msglog.cpp +++ b/plugins/Scriver/src/msglog.cpp @@ -719,7 +719,7 @@ static DWORD CALLBACK LogStreamInEvents(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG void StreamInTestEvents(HWND hEditWnd, GlobalMessageData *gdat) { - CSrmmWindow *dat = new CSrmmWindow(0); + CSrmmWindow *dat = new CSrmmWindow(0, false); LogStreamData streamData = { 0 }; streamData.isFirst = TRUE; diff --git a/plugins/Scriver/src/msgs.cpp b/plugins/Scriver/src/msgs.cpp index 1b3ac3df92..17101778c2 100644 --- a/plugins/Scriver/src/msgs.cpp +++ b/plugins/Scriver/src/msgs.cpp @@ -80,7 +80,7 @@ static INT_PTR ReadMessageCommand(WPARAM, LPARAM lParam) HWND hwndExisting = WindowList_Find(pci->hWindowList, hContact); if (hwndExisting == nullptr) - (new CSrmmWindow(hContact))->Show(); + (new CSrmmWindow(hContact, false))->Show(); else SendMessage(GetParent(hwndExisting), CM_POPUPWINDOW, 0, (LPARAM)hwndExisting); return 0; @@ -131,7 +131,7 @@ static int MessageEventAdded(WPARAM hContact, LPARAM lParam) ///////////////////////////////////////////////////////////////////////////////////////// -static INT_PTR SendMessageCommandWorker(MCONTACT hContact, LPCSTR pszMsg, bool isWchar) +static INT_PTR SendMessageCommandWorker(MCONTACT hContact, wchar_t *pszMsg) { hContact = db_mc_tryMeta(hContact); @@ -148,26 +148,28 @@ static INT_PTR SendMessageCommandWorker(MCONTACT hContact, LPCSTR pszMsg, bool i if (pszMsg) { HWND hEdit = GetDlgItem(hwnd, IDC_SRMM_MESSAGE); SendMessage(hEdit, EM_SETSEL, -1, GetWindowTextLength(hEdit)); - if (isWchar) - SendMessageW(hEdit, EM_REPLACESEL, FALSE, (LPARAM)pszMsg); - else - SendMessageA(hEdit, EM_REPLACESEL, FALSE, (LPARAM)pszMsg); + SendMessage(hEdit, EM_REPLACESEL, FALSE, (LPARAM)pszMsg); + mir_free(pszMsg); } SendMessage(GetParent(hwnd), CM_POPUPWINDOW, 0, (LPARAM)hwnd); } - else (new CSrmmWindow(hContact, false, pszMsg, isWchar))->Show(); + else { + CSrmmWindow *pDlg = new CSrmmWindow(hContact, false); + pDlg->m_wszInitialText = pszMsg; + pDlg->Show(); + } return 0; } static INT_PTR SendMessageCommandW(WPARAM hContact, LPARAM lParam) { - return SendMessageCommandWorker(hContact, LPCSTR(lParam), true); + return SendMessageCommandWorker(hContact, mir_a2u(LPCSTR(lParam))); } static INT_PTR SendMessageCommand(WPARAM hContact, LPARAM lParam) { - return SendMessageCommandWorker(hContact, LPCSTR(lParam), false); + return SendMessageCommandWorker(hContact, mir_wstrdup(LPCWSTR(lParam))); } ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/plugins/Scriver/src/msgs.h b/plugins/Scriver/src/msgs.h index 6782a5bee5..3ecd32a47a 100644 --- a/plugins/Scriver/src/msgs.h +++ b/plugins/Scriver/src/msgs.h @@ -116,7 +116,6 @@ class CSrmmWindow : public CScriverWindow virtual LRESULT WndProc_Log(UINT msg, WPARAM wParam, LPARAM lParam); virtual LRESULT WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam); - wchar_t *m_wszInitialText; bool m_bIncoming, m_bShowTyping; MEVENT m_hDbEventFirst, m_hDbEventLast, m_hDbUnreadEventFirst; @@ -159,11 +158,12 @@ public: int m_isMixed; bool m_bUseRtl, m_bUseIEView; + wchar_t *m_wszInitialText; HBITMAP m_hbmpAvatarPic; AVATARCACHEENTRY *m_ace; public: - CSrmmWindow(MCONTACT hContact, bool bIncoming = false, const char *szInitialText = nullptr, bool bIsUnicode = false); + CSrmmWindow(MCONTACT hContact, bool bIncoming); virtual void OnInitDialog() override; virtual void OnDestroy() override; diff --git a/plugins/TabSRMM/src/chat_window.cpp b/plugins/TabSRMM/src/chat_window.cpp index d73ca8f181..8e97de36f9 100644 --- a/plugins/TabSRMM/src/chat_window.cpp +++ b/plugins/TabSRMM/src/chat_window.cpp @@ -615,8 +615,6 @@ void CChatRoomDlg::OnDestroy() m_sbCustom = 0; } - M.RemoveWindow(m_hwnd); - NotifyEvent(MSG_WINDOW_EVT_CLOSE); m_pContainer->ClearMargins(); diff --git a/plugins/TabSRMM/src/mim.cpp b/plugins/TabSRMM/src/mim.cpp index 1737500343..f1c4e258e8 100644 --- a/plugins/TabSRMM/src/mim.cpp +++ b/plugins/TabSRMM/src/mim.cpp @@ -69,16 +69,6 @@ HWND CMimAPI::FindWindow(MCONTACT h) const return WindowList_Find(pci->hWindowList, h); } -INT_PTR CMimAPI::AddWindow(HWND hWnd, MCONTACT h) -{ - return WindowList_Add(pci->hWindowList, hWnd, h); -} - -INT_PTR CMimAPI::RemoveWindow(HWND hWnd) -{ - return WindowList_Remove(pci->hWindowList, hWnd); -} - ///////////////////////////////////////////////////////////////////////////////////////// int CMimAPI::FoldersPathChanged(WPARAM, LPARAM) diff --git a/plugins/TabSRMM/src/mim.h b/plugins/TabSRMM/src/mim.h index 5210cc4b25..183b96b6a6 100644 --- a/plugins/TabSRMM/src/mim.h +++ b/plugins/TabSRMM/src/mim.h @@ -181,8 +181,6 @@ public: // window lists void BroadcastMessage(UINT msg, WPARAM wParam, LPARAM lParam); void BroadcastMessageAsync(UINT msg, WPARAM wParam, LPARAM lParam); - INT_PTR AddWindow(HWND hWnd, MCONTACT h); - INT_PTR RemoveWindow(HWND hWnd); HWND FindWindow(MCONTACT h) const; static int FoldersPathChanged(WPARAM wParam, LPARAM lParam); // hook subscriber for folders plugin diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp index 9646963098..55e362f9f8 100644 --- a/plugins/TabSRMM/src/msgdialog.cpp +++ b/plugins/TabSRMM/src/msgdialog.cpp @@ -932,7 +932,6 @@ void CSrmmWindow::OnDestroy() UpdateTrayMenuState(this, FALSE); // remove me from the tray menu (if still there) if (PluginConfig.g_hMenuTrayUnread) DeleteMenu(PluginConfig.g_hMenuTrayUnread, m_hContact, MF_BYCOMMAND); - M.RemoveWindow(m_hwnd); if (m_cache->isValid()) db_set_dw(0, SRMSGMOD, "multisplit", m_iMultiSplit); diff --git a/plugins/TabSRMM/src/msgs.cpp b/plugins/TabSRMM/src/msgs.cpp index 5d3799b8a3..57e6949b92 100644 --- a/plugins/TabSRMM/src/msgs.cpp +++ b/plugins/TabSRMM/src/msgs.cpp @@ -96,7 +96,6 @@ void CTabBaseDlg::LoadSettings() void CTabBaseDlg::OnInitDialog() { CSrmmBaseDialog::OnInitDialog(); - SetWindowLongPtr(m_hwnd, GWLP_USERDATA, (LONG_PTR)this); // m_hwnd is valid, pass it to the tab control TCITEM tci; @@ -108,7 +107,6 @@ void CTabBaseDlg::OnInitDialog() m_pContainer->UpdateTabs(); // add this window to window list & proxy - M.AddWindow(m_hwnd, m_hContact); CProxyWindow::add(this); // set up Windows themes -- cgit v1.2.3