diff options
author | George Hazan <ghazan@miranda.im> | 2017-04-03 23:52:09 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2017-04-03 23:52:09 +0300 |
commit | 7f513673b523ecfbf6ded0a2d0e5cdf5496bd6b0 (patch) | |
tree | 676bd7211644596d2faf9e95cb0acf7f1f2cb7ee /plugins/Scriver | |
parent | 62cb48be341f443dbe356d37fb6d708167898ded (diff) |
- SRMM window list management moved to the base class;
- fixes #791
Diffstat (limited to 'plugins/Scriver')
-rw-r--r-- | plugins/Scriver/src/chat_window.cpp | 2 | ||||
-rw-r--r-- | plugins/Scriver/src/msgdialog.cpp | 8 | ||||
-rw-r--r-- | plugins/Scriver/src/msglog.cpp | 2 | ||||
-rw-r--r-- | plugins/Scriver/src/msgs.cpp | 20 | ||||
-rw-r--r-- | plugins/Scriver/src/msgs.h | 4 |
5 files changed, 15 insertions, 21 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;
|