summaryrefslogtreecommitdiff
path: root/src/core/stdpopup
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2022-09-26 18:23:52 +0300
committerGeorge Hazan <ghazan@miranda.im>2022-09-26 18:23:52 +0300
commit30a9e9e370aa9aff9f64158aa0942b471621a7ef (patch)
tree013f47dfcc748e7a816eb3b59a9ee852d34de0ad /src/core/stdpopup
parentcb0412427ffb4819f2026906f259f4a2dd3ef177 (diff)
Utils_ClipboardCopy - system-wide helper for writing text to clipboard
Diffstat (limited to 'src/core/stdpopup')
-rw-r--r--src/core/stdpopup/src/yapp_history_dlg.cpp50
1 files changed, 8 insertions, 42 deletions
diff --git a/src/core/stdpopup/src/yapp_history_dlg.cpp b/src/core/stdpopup/src/yapp_history_dlg.cpp
index 3751bb357a..dc6a5775ad 100644
--- a/src/core/stdpopup/src/yapp_history_dlg.cpp
+++ b/src/core/stdpopup/src/yapp_history_dlg.cpp
@@ -414,52 +414,18 @@ void RefreshPopupHistory(HWND hWnd, int renderer)
void CopyPopupDataToClipboard(HWND hList, int selection)
{
- if (!selection) {
+ if (!selection)
return;
- }
-
- if (!GetOpenClipboardWindow()) {
- if (OpenClipboard(hList)) {
- wchar_t buffer[2048];
- buffer[0] = '\0';
- wchar_t *clipboard;
- int i;
- int found = 0;
- int count = ListView_GetItemCount(hList);
- int textType;
-
- textType = CF_UNICODETEXT;
-
- for (i = 0; i < count; i++) {
- if (ListView_GetItemState(hList, i, LVIS_SELECTED)) {
- ListView_GetItemText(hList, i, selection - 100, buffer, _countof(buffer));
- found = 1;
- break;
- }
- }
- if (found) {
- EmptyClipboard();
- int len = (int)mir_wstrlen(buffer);
-
- HANDLE hData = GlobalAlloc(GMEM_MOVEABLE, (len + 2) * sizeof(wchar_t));
- clipboard = (wchar_t *)GlobalLock(hData);
- wcsncpy(clipboard, buffer, len);
- clipboard[len] = '\0';
- GlobalUnlock(hData);
- if (!SetClipboardData(textType, hData)) {
- PUShowMessage("Could not set clipboard data", SM_WARNING);
- }
- }
- CloseClipboard();
- }
- else {
- PUShowMessage("Could not open clipboard", SM_WARNING);
+ int count = ListView_GetItemCount(hList);
+ for (int i = 0; i < count; i++) {
+ if (ListView_GetItemState(hList, i, LVIS_SELECTED)) {
+ wchar_t buffer[2048]; buffer[0] = '\0';
+ ListView_GetItemText(hList, i, selection - 100, buffer, _countof(buffer));
+ Utils_ClipboardCopy(buffer);
+ break;
}
}
- else {
- PUShowMessage("The clipboard is not available", SM_WARNING);
- }
}
//subclass proc for the list view