diff options
author | George Hazan <ghazan@miranda.im> | 2022-09-26 18:23:52 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2022-09-26 18:23:52 +0300 |
commit | 30a9e9e370aa9aff9f64158aa0942b471621a7ef (patch) | |
tree | 013f47dfcc748e7a816eb3b59a9ee852d34de0ad /plugins/TabSRMM/src | |
parent | cb0412427ffb4819f2026906f259f4a2dd3ef177 (diff) |
Utils_ClipboardCopy - system-wide helper for writing text to clipboard
Diffstat (limited to 'plugins/TabSRMM/src')
-rw-r--r-- | plugins/TabSRMM/src/generic_msghandlers.cpp | 2 | ||||
-rw-r--r-- | plugins/TabSRMM/src/infopanel.cpp | 4 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgdlgother.cpp | 2 | ||||
-rw-r--r-- | plugins/TabSRMM/src/sendlater.cpp | 2 | ||||
-rw-r--r-- | plugins/TabSRMM/src/utils.cpp | 20 | ||||
-rw-r--r-- | plugins/TabSRMM/src/utils.h | 2 |
6 files changed, 5 insertions, 27 deletions
diff --git a/plugins/TabSRMM/src/generic_msghandlers.cpp b/plugins/TabSRMM/src/generic_msghandlers.cpp index 2236ad344a..9399fdc313 100644 --- a/plugins/TabSRMM/src/generic_msghandlers.cpp +++ b/plugins/TabSRMM/src/generic_msghandlers.cpp @@ -226,7 +226,7 @@ LRESULT CMsgDialog::DM_MsgWindowCmdHandler(UINT cmd, WPARAM wParam, LPARAM lPara case IDC_NAME: if (GetKeyState(VK_SHIFT) & 0x8000) // copy UIN - Utils::CopyToClipBoard(m_cache->getUIN(), m_hwnd); + Utils_ClipboardCopy(m_cache->getUIN()); else CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)(m_cache->getActiveContact()), 0); break; diff --git a/plugins/TabSRMM/src/infopanel.cpp b/plugins/TabSRMM/src/infopanel.cpp index cc7bed95c6..69b1400fcb 100644 --- a/plugins/TabSRMM/src/infopanel.cpp +++ b/plugins/TabSRMM/src/infopanel.cpp @@ -734,11 +734,11 @@ LRESULT CInfoPanel::cmdHandler(UINT cmd) switch (cmd) {
case CMD_IP_COPY:
if (m_hoverFlags & HOVER_NICK) {
- Utils::CopyToClipBoard(m_dat->m_cache->getNick(), m_dat->GetHwnd());
+ Utils_ClipboardCopy(m_dat->m_cache->getNick());
return(S_OK);
}
if (m_hoverFlags & HOVER_UIN) {
- Utils::CopyToClipBoard(m_isChat ? m_dat->m_si->ptszTopic : m_dat->m_cache->getUIN(), m_dat->GetHwnd());
+ Utils_ClipboardCopy(m_isChat ? m_dat->m_si->ptszTopic : m_dat->m_cache->getUIN());
return(S_OK);
}
break;
diff --git a/plugins/TabSRMM/src/msgdlgother.cpp b/plugins/TabSRMM/src/msgdlgother.cpp index 327439ab00..edaa0bacbc 100644 --- a/plugins/TabSRMM/src/msgdlgother.cpp +++ b/plugins/TabSRMM/src/msgdlgother.cpp @@ -2850,7 +2850,7 @@ LRESULT CMsgDialog::WMCopyHandler(UINT msg, WPARAM wParam, LPARAM lParam) ptrW converted(mir_utf8decodeW(szFromStream)); if (converted != nullptr) { Utils::FilterEventMarkers(converted); - Utils::CopyToClipBoard(converted, m_pLog->GetHwnd()); + Utils_ClipboardCopy(converted); } } diff --git a/plugins/TabSRMM/src/sendlater.cpp b/plugins/TabSRMM/src/sendlater.cpp index 77c23d8014..1ad1690076 100644 --- a/plugins/TabSRMM/src/sendlater.cpp +++ b/plugins/TabSRMM/src/sendlater.cpp @@ -442,7 +442,7 @@ public: job->writeFlags();
break;
case ID_QUEUEMANAGER_COPYMESSAGETOCLIPBOARD:
- Utils::CopyToClipBoard((wchar_t*)ptrW(mir_utf8decodeW(job->sendBuffer)), m_hwnd);
+ Utils_ClipboardCopy(ptrW(mir_utf8decodeW(job->sendBuffer)));
break;
case ID_QUEUEMANAGER_RESETSELECTED:
if (job->bCode == CSendLaterJob::JOB_DEFERRED) {
diff --git a/plugins/TabSRMM/src/utils.cpp b/plugins/TabSRMM/src/utils.cpp index 6dd803bac9..74fab10f8a 100644 --- a/plugins/TabSRMM/src/utils.cpp +++ b/plugins/TabSRMM/src/utils.cpp @@ -467,26 +467,6 @@ void Utils::setAvatarContact(HWND hWnd, MCONTACT hContact) }
/////////////////////////////////////////////////////////////////////////////////////////
-// stub for copying data to clipboard
-
-size_t Utils::CopyToClipBoard(const wchar_t *str, const HWND hwndOwner)
-{
- if (!OpenClipboard(hwndOwner) || str == nullptr)
- return 0;
-
- size_t i = sizeof(wchar_t) * (mir_wstrlen(str) + 1);
-
- EmptyClipboard();
- HGLOBAL hData = ::GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, i);
-
- memcpy((void*)GlobalLock(hData), str, i);
- GlobalUnlock(hData);
- SetClipboardData(CF_UNICODETEXT, hData);
- CloseClipboard();
- return i;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
HWND TSAPI GetTabWindow(HWND hwndTab, int i)
{
diff --git a/plugins/TabSRMM/src/utils.h b/plugins/TabSRMM/src/utils.h index 8eef84659c..f60cebe2e3 100644 --- a/plugins/TabSRMM/src/utils.h +++ b/plugins/TabSRMM/src/utils.h @@ -82,8 +82,6 @@ namespace Utils LRESULT CALLBACK PopupDlgProcError(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
LPTSTR extractURLFromRichEdit(const ENLINK* _e, const HWND hwndRich);
- size_t CopyToClipBoard(const wchar_t *str, const HWND hwndOwner);
-
//////////////////////////////////////////////////////////////////////////////////////
// safe mir_strlen function - do not overflow the given buffer length
// if the buffer does not contain a valid (zero-terminated) string, it
|