ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  How to copy to clipbaord in win32 c++?
Posted by Tim on May-12-2010 09:06
(My apologies - I posted this on the general forum but it belongs here)

We want to allow our users to paste an image (chart) directly to an email or other document without having to save a png file.

I am familiar with Clipboard API functions, but not exactly sure how to get the data/image from chartdirector.

Has anyone done this?  Any suggestions?

thanks

  Re: How to copy to clipbaord in win32 c++?
Posted by Tim on May-12-2010 09:44
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);