summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2017-04-03 23:52:09 +0300
committerGeorge Hazan <ghazan@miranda.im>2017-04-03 23:52:09 +0300
commit7f513673b523ecfbf6ded0a2d0e5cdf5496bd6b0 (patch)
tree676bd7211644596d2faf9e95cb0acf7f1f2cb7ee
parent62cb48be341f443dbe356d37fb6d708167898ded (diff)
- SRMM window list management moved to the base class;
- fixes #791
-rw-r--r--plugins/Scriver/src/chat_window.cpp2
-rw-r--r--plugins/Scriver/src/msgdialog.cpp8
-rw-r--r--plugins/Scriver/src/msglog.cpp2
-rw-r--r--plugins/Scriver/src/msgs.cpp20
-rw-r--r--plugins/Scriver/src/msgs.h4
-rw-r--r--plugins/TabSRMM/src/chat_window.cpp2
-rw-r--r--plugins/TabSRMM/src/mim.cpp10
-rw-r--r--plugins/TabSRMM/src/mim.h2
-rw-r--r--plugins/TabSRMM/src/msgdialog.cpp1
-rw-r--r--plugins/TabSRMM/src/msgs.cpp2
-rw-r--r--src/core/stdmsg/src/chat_window.cpp5
-rw-r--r--src/core/stdmsg/src/msgdialog.cpp5
-rw-r--r--src/mir_app/src/srmm_base.cpp5
13 files changed, 20 insertions, 48 deletions
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
diff --git a/src/core/stdmsg/src/chat_window.cpp b/src/core/stdmsg/src/chat_window.cpp
index aaf6ee3a50..ea68c9c571 100644
--- a/src/core/stdmsg/src/chat_window.cpp
+++ b/src/core/stdmsg/src/chat_window.cpp
@@ -55,7 +55,6 @@ void CChatRoomDlg::OnInitDialog()
{
CSrmmBaseDialog::OnInitDialog();
m_si->pDlg = this;
- SetWindowLongPtr(m_hwnd, GWLP_USERDATA, LPARAM(this));
if (g_Settings.bTabsEnable)
SetWindowLongPtr(m_hwnd, GWL_EXSTYLE, GetWindowLongPtr(m_hwnd, GWL_EXSTYLE) | WS_EX_APPWINDOW);
@@ -63,8 +62,6 @@ void CChatRoomDlg::OnInitDialog()
// initialize toolbar icons
Srmm_CreateToolbarIcons(m_hwnd, BBBF_ISCHATBUTTON);
- WindowList_Add(pci->hWindowList, m_hwnd, m_hContact);
-
NotifyEvent(MSG_WINDOW_EVT_OPENING);
m_log.SendMsg(EM_AUTOURLDETECT, 1, 0);
@@ -86,8 +83,6 @@ void CChatRoomDlg::OnDestroy()
{
NotifyEvent(MSG_WINDOW_EVT_CLOSING);
- WindowList_Remove(pci->hWindowList, m_hwnd);
-
m_si->pDlg = nullptr;
m_si->wState &= ~STATE_TALK;
diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp
index 4059a6ba1e..8b6ae10ed8 100644
--- a/src/core/stdmsg/src/msgdialog.cpp
+++ b/src/core/stdmsg/src/msgdialog.cpp
@@ -116,7 +116,6 @@ CSrmmWindow::CSrmmWindow(MCONTACT hContact) :
void CSrmmWindow::OnInitDialog()
{
CSrmmBaseDialog::OnInitDialog();
- SetWindowLongPtr(m_hwnd, GWLP_USERDATA, (LPARAM)this);
m_bIsMeta = db_mc_isMeta(m_hContact) != 0;
m_hTimeZone = TimeZone_CreateByContact(m_hContact, 0, TZF_KNOWNONLY);
@@ -156,7 +155,6 @@ void CSrmmWindow::OnInitDialog()
Srmm_CreateToolbarIcons(m_hwnd, BBBF_ISIMBUTTON);
- WindowList_Add(pci->hWindowList, m_hwnd, m_hContact);
GetWindowRect(m_message.GetHwnd(), &m_minEditInit);
SendMessage(m_hwnd, DM_UPDATESIZEBAR, 0, 0);
m_hwndStatus = nullptr;
@@ -284,7 +282,6 @@ void CSrmmWindow::OnInitDialog()
void CSrmmWindow::OnDestroy()
{
- SetWindowLongPtr(m_hwnd, GWLP_USERDATA, 0);
NotifyEvent(MSG_WINDOW_EVT_CLOSING);
// save string from the editor
@@ -308,8 +305,6 @@ void CSrmmWindow::OnDestroy()
mir_free(m_cmdList[i]);
m_cmdList.destroy();
- WindowList_Remove(pci->hWindowList, m_hwnd);
-
MCONTACT hContact = (g_dat.bSavePerContact) ? m_hContact : 0;
db_set_dw(hContact ? m_hContact : 0, SRMMMOD, "splitterPos", m_splitterPos);
diff --git a/src/mir_app/src/srmm_base.cpp b/src/mir_app/src/srmm_base.cpp
index 3c737fd772..62d744f540 100644
--- a/src/mir_app/src/srmm_base.cpp
+++ b/src/mir_app/src/srmm_base.cpp
@@ -577,6 +577,9 @@ LRESULT CSrmmBaseDialog::WndProc_Nicklist(UINT msg, WPARAM wParam, LPARAM lParam
void CSrmmBaseDialog::OnInitDialog()
{
+ WindowList_Add(chatApi.hWindowList, m_hwnd, m_hContact);
+ SetWindowLongPtr(m_hwnd, GWLP_USERDATA, (LONG_PTR)this);
+
SetWindowLongPtr(m_log.GetHwnd(), GWLP_USERDATA, LPARAM(this));
mir_subclassWindow(m_log.GetHwnd(), stubLogProc);
@@ -595,6 +598,8 @@ void CSrmmBaseDialog::OnInitDialog()
void CSrmmBaseDialog::OnDestroy()
{
+ WindowList_Remove(chatApi.hWindowList, m_hwnd);
+
SetWindowLongPtr(m_hwnd, GWLP_USERDATA, 0);
mir_unsubclassWindow(m_log.GetHwnd(), stubLogProc);
mir_unsubclassWindow(m_message.GetHwnd(), stubMessageProc);