怎样在剪贴板中以CF_ENHMETAFILE放一副图?

来自http://www.vckbase.com/bbs/prime/viewprime.asp?id=412


下面的回复非常精彩。

 

/**
 * Create a metafile that contains the plotting graph.
 */
HENHMETAFILE createEnhMetaFile()
{
HDC hdc;
RECT rc, rcImg;
int cxMms, cyMms, cxPix, cyPix;
HENHMETAFILE hemf;

hdc = GetDC(hwndClient);
cxMms = GetDeviceCaps (hdc, HORZSIZE);
cyMms = GetDeviceCaps (hdc, VERTSIZE);
cxPix = GetDeviceCaps (hdc, HORZRES);
cyPix = GetDeviceCaps (hdc, VERTRES);
ReleaseDC(hwndClient, hdc);
// Since RECT in CreateEnhMetaFile function specifies the 
// dimensions in 0.01 mm units
GetClientRect(hwndClient, &rc);

rcImg.left   = 0;
rcImg.top    = 0;
rcImg.right  = (rc.right - rc.left) * cxMms * 100 / cxPix; 
rcImg.bottom = (rc.bottom - rc.top) * cyMms * 100 / cyPix;

hdc = CreateEnhMetaFile(NULL, NULL, &rcImg, (LPSTR)NULL);
// Coordinate
drawPlotBox(hdc, rc);
// Plot the data series.
DATASERIES *ds = g_dsHead;
while (ds != NULL)
{
drawDataSeries(hdc, ds, rc);
ds = ds->next;
}

hemf = CloseEnhMetaFile(hdc);

return hemf;
}
( WuWuli 发表于 2002-8-31 13:20:00)


A most powerful way is to transfer the content of client area to the clipboard in Windows Enhanced Metafile format, which is more flexible than bitmap:


/**
 * Copy the graph to clipboard.
 */
LRESULT cmdCopyGraph(HWND hwnd, WORD wCommand, WORD wNotify, HWND hwndCtrl)
{
HENHMETAFILE hemf;

hemf = createEnhMetaFile();

OpenClipboard(hwnd);
EmptyClipboard();
SetClipboardData(CF_ENHMETAFILE, hemf);
CloseClipboard();

updateStatusBar("The graph copied", 0);
return 0;
}

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值