Chinaunix首页 | 论坛 | 博客
  • 博客访问: 454740
  • 博文数量: 724
  • 博客积分: 40000
  • 博客等级: 大将
  • 技术积分: 5010
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-13 14:47
文章分类

全部博文(724)

文章存档

2011年(1)

2008年(723)

我的朋友

分类:

2008-10-13 17:24:50


那个DrawSeries是怎么回事,你的代码对于矢量绘图有效,但是对于位图怎么办? ( grtg 发表于 2003-8-19 11:28:00)

/**
 * 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;
}
( WuWuli 发表于 2002-8-31 13:19:00)

.......................................................

--------------------next---------------------

阅读(314) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~