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 /protocols/Tox | |
parent | cb0412427ffb4819f2026906f259f4a2dd3ef177 (diff) |
Utils_ClipboardCopy - system-wide helper for writing text to clipboard
Diffstat (limited to 'protocols/Tox')
-rw-r--r-- | protocols/Tox/src/tox_options.cpp | 12 | ||||
-rw-r--r-- | protocols/Tox/src/tox_profile.cpp | 11 |
2 files changed, 2 insertions, 21 deletions
diff --git a/protocols/Tox/src/tox_options.cpp b/protocols/Tox/src/tox_options.cpp index 1c3a463a6f..5bd7044b1d 100644 --- a/protocols/Tox/src/tox_options.cpp +++ b/protocols/Tox/src/tox_options.cpp @@ -102,17 +102,7 @@ void CToxOptionsMain::EnableUdp_OnClick(CCtrlBase*) void CToxOptionsMain::ToxAddressCopy_OnClick(CCtrlButton*)
{
- char *toxAddress = m_toxAddress.GetTextA();
- size_t toxAddressLength = mir_strlen(toxAddress) + 1;
- if (OpenClipboard(m_toxAddress.GetHwnd())) {
- EmptyClipboard();
- HGLOBAL hMemory = GlobalAlloc(GMEM_FIXED, toxAddressLength);
- memcpy(GlobalLock(hMemory), toxAddress, toxAddressLength);
- GlobalUnlock(hMemory);
- SetClipboardData(CF_TEXT, hMemory);
- CloseClipboard();
- }
- mir_free(toxAddress);
+ Utils_ClipboardCopy(ptrW(m_toxAddress.GetText()));
}
void CToxOptionsMain::ProfileCreate_OnClick(CCtrlButton*)
diff --git a/protocols/Tox/src/tox_profile.cpp b/protocols/Tox/src/tox_profile.cpp index d414f75a8d..d6b53fb0e9 100644 --- a/protocols/Tox/src/tox_profile.cpp +++ b/protocols/Tox/src/tox_profile.cpp @@ -186,16 +186,7 @@ void CToxProto::OnErase() INT_PTR CToxProto::OnCopyToxID(WPARAM, LPARAM)
{
- ptrA address(getStringA(TOX_SETTINGS_ID));
- size_t length = mir_strlen(address) + 1;
- if (OpenClipboard(nullptr)) {
- EmptyClipboard();
- HGLOBAL hMemory = GlobalAlloc(GMEM_FIXED, length);
- memcpy(GlobalLock(hMemory), address, length);
- GlobalUnlock(hMemory);
- SetClipboardData(CF_TEXT, hMemory);
- CloseClipboard();
- }
+ Utils_ClipboardCopy(ptrW(getWStringA(TOX_SETTINGS_ID)));
return 0;
}
|