| 1401 | } |
| 1402 | |
| 1403 | void CColorCopDlg::OnCopytoclip() { |
| 1404 | if (m_Appflags & AutoCopytoClip) { |
| 1405 | HWND hWndOwner = ::GetForegroundWindow(); |
| 1406 | |
| 1407 | if (::OpenClipboard(hWndOwner)) { |
| 1408 | ::EmptyClipboard(); |
| 1409 | |
| 1410 | // CString is UTF‑16 in Unicode builds, so copy its raw buffer. |
| 1411 | const int len = m_Hexcolor.GetLength(); |
| 1412 | const SIZE_T bytes = (len + 1) * sizeof(wchar_t); |
| 1413 | |
| 1414 | HGLOBAL hMem = ::GlobalAlloc(GMEM_MOVEABLE, bytes); |
| 1415 | if (hMem) { |
| 1416 | void* pMem = ::GlobalLock(hMem); |
| 1417 | if (pMem) { |
| 1418 | std::memcpy(pMem, m_Hexcolor.GetString(), bytes); |
| 1419 | ::GlobalUnlock(hMem); |
| 1420 | |
| 1421 | // Correct modern clipboard format |
| 1422 | ::SetClipboardData(CF_UNICODETEXT, hMem); |
| 1423 | } else { |
| 1424 | ::GlobalFree(hMem); |
| 1425 | } |
| 1426 | } |
| 1427 | |
| 1428 | ::CloseClipboard(); |
| 1429 | } |
| 1430 | } |
| 1431 | } |
| 1432 | |
| 1433 | void CColorCopDlg::StopCapture() { |
| 1434 | // we don't want to capture anymore, they let up the left mouse button, or hit ESC |
nothing calls this directly
no outgoing calls
no test coverage detected