VC中复制位图到剪切板,粘贴到word!!!
我打算在VC中复制位图到剪切板,然后在调用word粘贴,下面程序执行一次可以,为什么,继续调用就出错了, 就是这句 pData->SetClipboard();??????
COLORREF BACKGROUND_COLOR = RGB(255,255,255);
tagSTGMEDIUM * data;
CBitmap * junk;
COleDataSource* pData = new COleDataSource;
data = new tagSTGMEDIUM;
junk = new CBitmap();
CClientDC cdc(this);
CDC dc;
dc.CreateCompatibleDC(&cdc);
CRect client;
//replace this with something that calculates
//the proper rectangle size
GetClientRect(client);
junk->CreateCompatibleBitmap(&cdc,client.Width(),client.Height());
dc.SelectObject(junk);
CBrush fill(BACKGROUND_COLOR);
dc.FillRect(client,&fill);
//replace this with something that draws to a CDC
OnDraw(&dc);
data->tymed = TYMED_GDI;
data->hBitmap = HBITMAP(*junk);
pData->CacheData( CF_BITMAP, data );
pData->SetClipboard();
delete data;
delete junk;