From c5dc28ec2272a865ef2f28fd7ab151b55517fedf Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 26 Sep 2022 19:16:12 +0300 Subject: more clipboard shit removed --- plugins/SimpleStatusMsg/src/awaymsg.cpp | 48 +++++---------------------------- plugins/SimpleStatusMsg/src/msgbox.cpp | 27 +++---------------- 2 files changed, 10 insertions(+), 65 deletions(-) (limited to 'plugins/SimpleStatusMsg/src') 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; } -- cgit v1.2.3