来自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;
}
本文介绍了一种使用Windows增强型元文件格式复制客户端区域内容到剪贴板的方法,这种方式比位图更为灵活。文章提供了具体的代码实现,包括创建包含绘图的元文件和将这些内容复制到剪贴板的过程。
1277

被折叠的 条评论
为什么被折叠?



