This seems to work:
MemBlock block = chart.makeChart(Chart::BMP);
HGLOBAL hResult;
if (!OpenClipboard()) return ;
if (!EmptyClipboard()) return ;
size_t buflen = block.len - sizeof(BITMAPFILEHEADER);
hResult = GlobalAlloc(GMEM_MOVEABLE, buflen);
if (hResult == NULL) return ;
memcpy(GlobalLock(hResult), block.data + sizeof(BITMAPFILEHEADER), buflen);
GlobalUnlock(hResult);
if (SetClipboardData(CF_DIB, hResult) == NULL)
{
CloseClipboard();
}
CloseClipboard();
GlobalFree(hResult); |