summaryrefslogtreecommitdiff
path: root/plugins/SimpleStatusMsg/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2022-09-26 19:16:12 +0300
committerGeorge Hazan <ghazan@miranda.im>2022-09-26 19:16:12 +0300
commitc5dc28ec2272a865ef2f28fd7ab151b55517fedf (patch)
treed751f3e869c66371b8f1d65480b39c2997ba6e62 /plugins/SimpleStatusMsg/src
parentdc2a4dc50d6cc3e7bd513122756dd39141d7887e (diff)
more clipboard shit removed
Diffstat (limited to 'plugins/SimpleStatusMsg/src')
-rw-r--r--plugins/SimpleStatusMsg/src/awaymsg.cpp48
-rw-r--r--plugins/SimpleStatusMsg/src/msgbox.cpp27
2 files changed, 10 insertions, 65 deletions
diff --git a/plugins/SimpleStatusMsg/src/awaymsg.cpp b/plugins/SimpleStatusMsg/src/awaymsg.cpp
index 6d25de503b..e034dc3009 100644
--- a/plugins/SimpleStatusMsg/src/awaymsg.cpp
+++ b/plugins/SimpleStatusMsg/src/awaymsg.cpp
@@ -115,28 +115,9 @@ public:
void onClick_Copy(CCtrlButton*)
{
- if (!OpenClipboard(m_hwnd))
- return;
-
- if (EmptyClipboard()) {
- wchar_t msg[1024];
- int len = GetDlgItemText(m_hwnd, IDC_MSG, msg, _countof(msg));
- if (len) {
- LPTSTR lptstrCopy;
- HGLOBAL hglbCopy = GlobalAlloc(GMEM_MOVEABLE, (len + 1) * sizeof(wchar_t));
- if (hglbCopy == nullptr) {
- CloseClipboard();
- return;
- }
- lptstrCopy = (LPTSTR)GlobalLock(hglbCopy);
- memcpy(lptstrCopy, msg, len * sizeof(wchar_t));
- lptstrCopy[len] = (wchar_t)0;
- GlobalUnlock(hglbCopy);
-
- SetClipboardData(CF_UNICODETEXT, hglbCopy);
- }
- }
- CloseClipboard();
+ wchar_t msg[1024];
+ GetDlgItemText(m_hwnd, IDC_MSG, msg, _countof(msg));
+ Utils_ClipboardCopy(msg);
}
};
@@ -203,25 +184,10 @@ public:
m_hAwayMsgEvent = nullptr;
}
- if (OpenClipboard(m_hwnd)) {
- if (EmptyClipboard()) {
- CMStringW wszMsg((wchar_t *)ack->lParam);
- wszMsg.Replace(L"\n", L"\r\n");
- if (wszMsg.GetLength()) {
- LPTSTR lptstrCopy;
- HGLOBAL hglbCopy = GlobalAlloc(GMEM_MOVEABLE, (wszMsg.GetLength() + 1) * sizeof(wchar_t));
- if (hglbCopy != nullptr) {
- lptstrCopy = (LPTSTR)GlobalLock(hglbCopy);
- memcpy(lptstrCopy, wszMsg, wszMsg.GetLength() * sizeof(wchar_t));
- lptstrCopy[wszMsg.GetLength()] = 0;
- GlobalUnlock(hglbCopy);
-
- SetClipboardData(CF_UNICODETEXT, hglbCopy);
- }
- }
- }
- CloseClipboard();
- }
+ CMStringW wszMsg((wchar_t *)ack->lParam);
+ wszMsg.Replace(L"\n", L"\r\n");
+ Utils_ClipboardCopy(wszMsg);
+
Close();
}
diff --git a/plugins/SimpleStatusMsg/src/msgbox.cpp b/plugins/SimpleStatusMsg/src/msgbox.cpp
index 20d1a60343..6c21e44ef9 100644
--- a/plugins/SimpleStatusMsg/src/msgbox.cpp
+++ b/plugins/SimpleStatusMsg/src/msgbox.cpp
@@ -461,30 +461,9 @@ VOID APIENTRY HandlePopupMenu(HWND hwnd, POINT pt, HWND edit_control)
break;
default:
- if (!OpenClipboard(GetParent(hwnd)))
- break;
-
- if (EmptyClipboard()) {
- wchar_t item_string[128];
- GetMenuString(hmenu, m_selection, (LPTSTR)&item_string, 128, MF_BYCOMMAND);
-
- int len = (int)mir_wstrlen(item_string);
- if (len) {
- LPTSTR lptstrCopy;
- HGLOBAL hglbCopy = GlobalAlloc(GMEM_MOVEABLE, (len + 1) * sizeof(wchar_t));
- if (hglbCopy == nullptr) {
- CloseClipboard();
- break;
- }
- lptstrCopy = (LPTSTR)GlobalLock(hglbCopy);
- memcpy(lptstrCopy, item_string, len * sizeof(wchar_t));
- lptstrCopy[len] = (wchar_t)0;
- GlobalUnlock(hglbCopy);
-
- SetClipboardData(CF_UNICODETEXT, hglbCopy);
- }
- }
- CloseClipboard();
+ wchar_t item_string[128];
+ GetMenuString(hmenu, m_selection, (LPTSTR)&item_string, 128, MF_BYCOMMAND);
+ Utils_ClipboardCopy(item_string);
SendMessage(edit_control, WM_PASTE, 0, 0);
break;
}