饼状图的问题 谁有饼状图(比例图),给我一份源码,谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://www.codeproject.com/miscctrl/pie_chart_ctrl.asp MSchart 你可以用这个控件! MSchart 控件有一个函数叫editcopy吧,可以把当前的并图放到剪贴板里,打印的时候直接打印剪贴板的内容就行了。 MSchart 控件有一个函数叫editcopy吧,可以把当前的并图放到剪贴板里,打印的时候直接打印剪贴板的内容就行了。具体些,能给个例子吗 MSchart 控件有一个函数叫editcopy吧,可以把当前的并图放到剪贴板里,打印的时候直接打印剪贴板的内容就行了。具体些,能给个例子吗 MSchart 控件有一个函数叫editcopy吧,可以把当前的并图放到剪贴板里,打印的时候直接打印剪贴板的内容就行了。具体些,能给个例子吗 http://www.vcfan.com/vc/down_children.asp?child_name=codes_kongjian&page=2第1335(编号) http://www.vcfan.com/vc/down_children.asp?child_name=codes_kongjian&page=2第1335(编号)里面没有打印这一项? 我有mschart的使用例子,但是公司的项目,不敢给你啊!呵呵 在OnPreparePrinting中:如果是饼图打印 pChartLine->EditCopy(); if(IsClipboardFormatAvailable(CF_BITMAP)) { if(OpenClipboard()) { m_hbitmap = (HBITMAP)::GetClipboardData(CF_BITMAP); CloseClipboard(); } } 在OnPrint里;CRect rectPage = pInfo->m_rectDraw; if(m_hbitmap) { BITMAP bm; ::GetObject(m_hbitmap, sizeof(BITMAP), &bm); CSize chartSize(bm.bmWidth, bm.bmHeight); CDC dcMemory,dcScreen; dcScreen.Attach(::GetDC(NULL)); // create "from" device context and select the loaded bitmap into it dcMemory.CreateCompatibleDC(&dcScreen); dcMemory.SelectObject(m_hbitmap); // Print at 85% size within left/right margin CSize printSize; printSize.cx=(int)(rectPage.right*.85); printSize.cy=printSize.cx/chartSize.cx*chartSize.cy; CRect rect(0,0,printSize.cx,printSize.cy); // Print chart centered pDC->StretchBlt( ((rectPage.right+rectPage.left)/2)-(printSize.cx/2), rectPage.top, printSize.cx, printSize.cy, &dcMemory, 0, 0, chartSize.cx, chartSize.cy, SRCCOPY); dcMemory.DeleteDC(); }就可以打印剪贴板里的内容 在OnPreparePrinting中:如果是饼图打印 pChartLine->EditCopy(); //////pChartLine是什么 if(IsClipboardFormatAvailable(CF_BITMAP)) ////////CF_BITMAP是什么 { if(OpenClipboard()) { m_hbitmap = (HBITMAP)::GetClipboardData(CF_BITMAP); CloseClipboard(); } } 在OnPrint里;CRect rectPage = pInfo->m_rectDraw; ///////pInfo是什么 if(m_hbitmap) ////////m_hbitmap是什么 { BITMAP bm; ::GetObject(m_hbitmap, sizeof(BITMAP), &bm); CSize chartSize(bm.bmWidth, bm.bmHeight); CDC dcMemory,dcScreen; dcScreen.Attach(::GetDC(NULL)); // create "from" device context and select the loaded bitmap into it dcMemory.CreateCompatibleDC(&dcScreen); dcMemory.SelectObject(m_hbitmap); // Print at 85% size within left/right margin CSize printSize; printSize.cx=(int)(rectPage.right*.85); printSize.cy=printSize.cx/chartSize.cx*chartSize.cy; CRect rect(0,0,printSize.cx,printSize.cy); // Print chart centered pDC->StretchBlt( ((rectPage.right+rectPage.left)/2)-(printSize.cx/2), rectPage.top, printSize.cx, printSize.cy, &dcMemory, 0, 0, chartSize.cx, chartSize.cy, SRCCOPY); dcMemory.DeleteDC(); }就可以打印剪贴板里的内容 该代码可以打印对话框上显示的饼图吗?OnPreparePrinting,OnPrint在CDialog中不能用吧? 我的是再FormView里的。pChartLine是msChart控件的句柄CF_BITMAP是告诉剪贴板要考的bitmap图像pInfo是CTestocxPrintViewView::OnPrint(CDC* pDC, CPrintInfo* pInfo)里的。打印变量的指针。m_hbitmap是一个 CBitmap,全局变量,用来判断剪贴板是否有位图 http://www.codeproject.com/miscctrl/pie_chart_ctrl.asp里有饼图方式下的程序,但不带打印功能, 它是在对话框上放了一个Custom control控件,属性里Class是PIE_CHART_CTRL,Style是0x50010000,在对话框的初始化里边有语句: m_wndChart.SubclassDlgItem(IDC_PIECHART1, this);如何写 pChartLine->EditCopy(); pChartLine如何被替换掉 如何把http://www.codeproject.com/miscctrl/pie_chart_ctrl.asp里的饼图打印出来 http://www.codeproject.com/miscctrl/pie_chart_ctrl.asp里有饼图方式下的程序,但不带打印功能, 它是在对话框上放了一个Custom control控件,属性里Class是PIE_CHART_CTRL,Style是0x50010000,在对话框的初始化里边有语句: m_wndChart.SubclassDlgItem(IDC_PIECHART1, this);我画饼图 用的是这种方式,不是把mschart控件直接放在对话框上,这样打印不一样吧?pChartLine->EditCopy();这句不一样,我的m_wndChart不是mschart类型,而pChartLine是mschart类型 editcopy是mschart的一个函数。其实他editcopy做的事就是找到饼图区域,然后把他给截下来,再放到剪贴板。就这么多,你用别的控件也可以啊,只不过要自己写这个过程。 如何把Custom control控件区域内的所有东西作为一个bitmap截下来 HBITMAP CopyScreenToBitmap(LPRECT lpRect) //lpRect 代表选定区域{HDC hScrDC, hMemDC; // 屏幕和内存设备描述表HBITMAP hBitmap, hOldBitmap; // 位图句柄int nX, nY, nX2, nY2; // 选定区域坐标int nWidth, nHeight; // 位图宽度和高度int xScrn, yScrn; // 屏幕分辨率 if (IsRectEmpty(lpRect))// 确保选定区域不为空矩形 return NULL; //为屏幕创建设备描述表 hScrDC = CreateDC("DISPLAY", NULL, NULL, NULL); //为屏幕设备描述表创建兼容的内存设备描述表 hMemDC = CreateCompatibleDC(hScrDC); // 获得选定区域坐标 nX = lpRect- >left; nY = lpRect- >top; nX2 = lpRect- >right; nY2 = lpRect- >bottom; // 获得屏幕分辨率 xScrn = GetDeviceCaps(hScrDC, HORZRES); yScrn = GetDeviceCaps(hScrDC, VERTRES); //确保选定区域是可见的 if (nX < 0) nX = 0; if (nY < 0) nY = 0; if (nX2 > xScrn) nX2 = xScrn; if (nY2 > yScrn) nY2 = yScrn; nWidth = nX2 - nX; nHeight = nY2 - nY; 接上// 创建一个与屏幕设备描述表兼容的位图hBitmap = CreateCompatibleBitmap (hScrDC, nWidth, nHeight); // 把新位图选到内存设备描述表中 hOldBitmap = SelectObject(hMemDC, hBitmap); // 把屏幕设备描述表拷贝到内存设备描述表中BitBlt(hMemDC, 0, 0, nWidth, nHeight, hScrDC, nX, nY, SRCCOPY); //得到屏幕位图的句柄 hBitmap = SelectObject(hMemDC, hOldBitmap); //清除 DeleteDC(hScrDC); DeleteDC(hMemDC); // 返回位图句柄 return hBitmap;} yushulei(永远) :这些你都敢贴啊》》》》》 HBITMAP CopyScreenToBitmap(LPRECT lpRect)中lpRect是屏幕坐标还是客户区坐标 我的饼图画在对话框上,在对话框里m_hbitmap=CopyScreenToBitmap(lpRect);m_hbitmap是在程序的应用类里声明的HBITMAP m_hbitmap;这样我在程序的视图类里,p是CStatListApp*void CStatListView::OnPrint(CDC* pDC, CPrintInfo* pInfo) { CStatisticsApp* p=(CStatisticsApp*)::AfxGetApp(); CRect rectPage = pInfo->m_rectDraw; if(p->m_hbitmap) { BITMAP bm; ::GetObject(p->m_hbitmap, sizeof(BITMAP), &bm); CSize chartSize(bm.bmWidth, bm.bmHeight); CDC dcMemory,dcScreen; dcScreen.Attach(::GetDC(NULL)); // create "from" device context and select the loaded bitmap into it dcMemory.CreateCompatibleDC(&dcScreen); dcMemory.SelectObject(p->m_hbitmap); // Print at 85% size within left/right margin CSize printSize; printSize.cx=(int)(rectPage.right*.85); printSize.cy=printSize.cx/chartSize.cx*chartSize.cy; CRect rect(0,0,printSize.cx,printSize.cy); // Print chart centered pDC->StretchBlt( ((rectPage.right+rectPage.left)/2)-(printSize.cx/2), rectPage.top, printSize.cx, printSize.cy, &dcMemory, 0, 0, chartSize.cx, chartSize.cy, SRCCOPY); dcMemory.DeleteDC(); } CListView::OnPrint(pDC, pInfo);}不能大出结果,为什么 我的饼图已经放在剪贴板里,按照上面的方法,而且在打印预览里也显示出来了,打印工作放在OnDraw里, pDC->SetMapMode( MM_TEXT); if(m_hbitmap) { BITMAP bm; ::GetObject(p->m_hbitmap, sizeof(BITMAP), &bm); CSize chartSize(bm.bmWidth, bm.bmHeight); CDC dcMemory,dcScreen; dcScreen.Attach(::GetDC(NULL)); // create "from" device context and select the loaded bitmap into it dcMemory.CreateCompatibleDC(&dcScreen); dcMemory.SelectObject(p->m_hbitmap); // Print at 85% size within left/right margin CSize printSize; printSize.cx=(int)(rectPage.right*.85); printSize.cy=printSize.cx/chartSize.cx*chartSize.cy; CRect rect(0,0,printSize.cx,printSize.cy);// Print chart centered pDC->StretchBlt(500 ,rectPage.bottom-printSize.cy, printSize.cx, printSize.cy, &dcMemory, 0, 0, chartSize.cx, chartSize.cy, SRCCOPY); dcMemory.DeleteDC(); }为啥不能打印出来 vc 动态重复创建关联的子窗口,出错! 100分全部送了,求解决zlib问题? DCOM调用失败问题 切分窗口中使用了一个对话框,如何改变对话框的颜色呢?谢谢 如何删除ctrl-x,ctrl-c,等ctrl组合键消息? 是否是线程安全问题? 如何读取.dat文件 求助有关winpcap的问题 各位都来这里一下啦!! 为什么参数传递不到函数中? 如何在single document中添加对话框!帮帮忙! activeX控件的动态创建问题 to(Microsoftadherent(王万新) )
剪贴板里,打印的时候直接打印剪贴板的内容就行了。
剪贴板里,打印的时候直接打印剪贴板的内容就行了。具体些,能给个例子吗
剪贴板里,打印的时候直接打印剪贴板的内容就行了。具体些,能给个例子吗
剪贴板里,打印的时候直接打印剪贴板的内容就行了。具体些,能给个例子吗
第1335(编号)
第1335(编号)里面没有打印这一项?
pChartLine->EditCopy();
if(IsClipboardFormatAvailable(CF_BITMAP))
{
if(OpenClipboard())
{
m_hbitmap = (HBITMAP)::GetClipboardData(CF_BITMAP);
CloseClipboard();
}
}
CRect rectPage = pInfo->m_rectDraw;
if(m_hbitmap)
{
BITMAP bm;
::GetObject(m_hbitmap, sizeof(BITMAP), &bm);
CSize chartSize(bm.bmWidth, bm.bmHeight);
CDC dcMemory,dcScreen;
dcScreen.Attach(::GetDC(NULL));
// create "from" device context and select the loaded bitmap into it
dcMemory.CreateCompatibleDC(&dcScreen);
dcMemory.SelectObject(m_hbitmap);
// Print at 85% size within left/right margin
CSize printSize;
printSize.cx=(int)(rectPage.right*.85);
printSize.cy=printSize.cx/chartSize.cx*chartSize.cy;
CRect rect(0,0,printSize.cx,printSize.cy);
// Print chart centered
pDC->StretchBlt( ((rectPage.right+rectPage.left)/2)-(printSize.cx/2), rectPage.top, printSize.cx, printSize.cy, &dcMemory, 0, 0, chartSize.cx, chartSize.cy, SRCCOPY);
dcMemory.DeleteDC();
}
就可以打印剪贴板里的内容
在OnPreparePrinting中:如果是饼图打印
pChartLine->EditCopy(); //////pChartLine是什么
if(IsClipboardFormatAvailable(CF_BITMAP)) ////////CF_BITMAP是什么
{
if(OpenClipboard())
{
m_hbitmap = (HBITMAP)::GetClipboardData(CF_BITMAP);
CloseClipboard();
}
}
在OnPrint里;
CRect rectPage = pInfo->m_rectDraw; ///////pInfo是什么
if(m_hbitmap) ////////m_hbitmap是什么
{
BITMAP bm;
::GetObject(m_hbitmap, sizeof(BITMAP), &bm);
CSize chartSize(bm.bmWidth, bm.bmHeight);
CDC dcMemory,dcScreen;
dcScreen.Attach(::GetDC(NULL));
// create "from" device context and select the loaded bitmap into it
dcMemory.CreateCompatibleDC(&dcScreen);
dcMemory.SelectObject(m_hbitmap);
// Print at 85% size within left/right margin
CSize printSize;
printSize.cx=(int)(rectPage.right*.85);
printSize.cy=printSize.cx/chartSize.cx*chartSize.cy;
CRect rect(0,0,printSize.cx,printSize.cy);
// Print chart centered
pDC->StretchBlt( ((rectPage.right+rectPage.left)/2)-(printSize.cx/2), rectPage.top, printSize.cx, printSize.cy, &dcMemory, 0, 0, chartSize.cx, chartSize.cy, SRCCOPY);
dcMemory.DeleteDC();
}
就可以打印剪贴板里的内容
OnPreparePrinting,OnPrint在CDialog中不能用吧?
pChartLine是msChart控件的句柄
CF_BITMAP是告诉剪贴板要考的bitmap图像
pInfo是CTestocxPrintViewView::OnPrint(CDC* pDC, CPrintInfo* pInfo)里的。打印变量的指针。
m_hbitmap是一个 CBitmap,全局变量,用来判断剪贴板是否有位图
里有饼图方式下的程序,但不带打印功能, 它是在对话框上放了一个Custom control控件,
属性里Class是PIE_CHART_CTRL,Style是0x50010000,在对话框的初始化里边有语句: m_wndChart.SubclassDlgItem(IDC_PIECHART1, this);如何写 pChartLine->EditCopy(); pChartLine如何被替换掉
里有饼图方式下的程序,但不带打印功能, 它是在对话框上放了一个Custom control控件,
属性里Class是PIE_CHART_CTRL,Style是0x50010000,在对话框的初始化里边有语句: m_wndChart.SubclassDlgItem(IDC_PIECHART1, this);
我画饼图 用的是这种方式,不是把mschart控件直接放在对话框上,这样打印不一样吧?
pChartLine->EditCopy();这句不一样,我的m_wndChart不是mschart类型,而pChartLine是mschart类型
就这么多,你用别的控件也可以啊,只不过要自己写这个过程。
{
HDC hScrDC, hMemDC; // 屏幕和内存设备描述表
HBITMAP hBitmap, hOldBitmap; // 位图句柄int nX, nY, nX2, nY2; // 选定区域坐标
int nWidth, nHeight; // 位图宽度和高度
int xScrn, yScrn; // 屏幕分辨率
if (IsRectEmpty(lpRect))// 确保选定区域不为空矩形
return NULL;
hScrDC = CreateDC("DISPLAY", NULL, NULL, NULL);
//为屏幕设备描述表创建兼容的内存设备描述表
hMemDC = CreateCompatibleDC(hScrDC);
// 获得选定区域坐标
nX = lpRect- >left;
nY = lpRect- >top;
nX2 = lpRect- >right;
nY2 = lpRect- >bottom;
// 获得屏幕分辨率
xScrn = GetDeviceCaps(hScrDC, HORZRES);
yScrn = GetDeviceCaps(hScrDC, VERTRES);
//确保选定区域是可见的
if (nX < 0)
nX = 0;
if (nY < 0)
nY = 0;
if (nX2 > xScrn)
nX2 = xScrn;
if (nY2 > yScrn)
nY2 = yScrn;
nWidth = nX2 - nX;
nHeight = nY2 - nY;
// 创建一个与屏幕设备描述表兼容的位图
hBitmap = CreateCompatibleBitmap
(hScrDC, nWidth, nHeight);
// 把新位图选到内存设备描述表中
hOldBitmap = SelectObject(hMemDC, hBitmap);
// 把屏幕设备描述表拷贝到内存设备描述表中
BitBlt(hMemDC, 0, 0, nWidth, nHeight, hScrDC, nX, nY, SRCCOPY);
//得到屏幕位图的句柄
hBitmap = SelectObject(hMemDC, hOldBitmap);
//清除
DeleteDC(hScrDC);
DeleteDC(hMemDC);
// 返回位图句柄
return hBitmap;
}
这些你都敢贴啊》》》》》
中lpRect是屏幕坐标还是客户区坐标
m_hbitmap=CopyScreenToBitmap(lpRect);m_hbitmap是在程序的应用类里声明的HBITMAP m_hbitmap;这样我在程序的视图类里,p是CStatListApp*
void CStatListView::OnPrint(CDC* pDC, CPrintInfo* pInfo)
{
CStatisticsApp* p=(CStatisticsApp*)::AfxGetApp();
CRect rectPage = pInfo->m_rectDraw;
if(p->m_hbitmap)
{
BITMAP bm;
::GetObject(p->m_hbitmap, sizeof(BITMAP), &bm);
CSize chartSize(bm.bmWidth, bm.bmHeight);
CDC dcMemory,dcScreen;
dcScreen.Attach(::GetDC(NULL));
// create "from" device context and select the loaded bitmap into it
dcMemory.CreateCompatibleDC(&dcScreen);
dcMemory.SelectObject(p->m_hbitmap);
// Print at 85% size within left/right margin
CSize printSize;
printSize.cx=(int)(rectPage.right*.85);
printSize.cy=printSize.cx/chartSize.cx*chartSize.cy;
CRect rect(0,0,printSize.cx,printSize.cy);
// Print chart centered
pDC->StretchBlt( ((rectPage.right+rectPage.left)/2)-(printSize.cx/2), rectPage.top, printSize.cx, printSize.cy, &dcMemory, 0, 0, chartSize.cx, chartSize.cy, SRCCOPY);
dcMemory.DeleteDC();
} CListView::OnPrint(pDC, pInfo);
}不能大出结果,为什么
pDC->SetMapMode( MM_TEXT);
if(m_hbitmap)
{
BITMAP bm;
::GetObject(p->m_hbitmap, sizeof(BITMAP), &bm);
CSize chartSize(bm.bmWidth, bm.bmHeight);
CDC dcMemory,dcScreen;
dcScreen.Attach(::GetDC(NULL));
// create "from" device context and select the loaded bitmap into it dcMemory.CreateCompatibleDC(&dcScreen);
dcMemory.SelectObject(p->m_hbitmap);
// Print at 85% size within left/right margin
CSize printSize;
printSize.cx=(int)(rectPage.right*.85);
printSize.cy=printSize.cx/chartSize.cx*chartSize.cy;
CRect rect(0,0,printSize.cx,printSize.cy);// Print chart centered
pDC->StretchBlt(500 ,rectPage.bottom-printSize.cy, printSize.cx, printSize.cy, &dcMemory, 0, 0, chartSize.cx, chartSize.cy, SRCCOPY);
dcMemory.DeleteDC();
}
为啥不能打印出来