如何实现Form的打印 设置一个按钮,当点击该按钮的时候调用WINDOW.PRINT方法。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 好像不对啊。只有System.Windows.Forms.PrintDialog……能说清楚点吗?要使用什么名字空间? 可是试试在发生Paint的时候保存里面的Graphics对象在需要的时候处理(比如输出到打印机或者保存为图片) 好像要用到报表.ReportDocument但是不知道怎么设置 打印的组件在System.Drawing.Printing创建一个PrintDocument对象,加上BeginPrint, PrintPage的响应调用他的void Print()的方法在PrintPage的PrintPageEventArgs的参数中有Graphics的属性,可以通过这个属性绘画。不过我遇到一个问题,Framework的打印组件在WinXP,Win2k中非常稳定,但在Win98,WinME中就经常会出错,特别是PrintPreviewControl的控件 基本的方法是把form graphics里面的东西照样在print里面画一遍 我手头有例子留下你的mail? to anamnesis: 請給我一份 [email protected] thanking of you Me too, [email protected] thank you [email protected] 感谢您使用微软产品您可以调用BitBlt API将整个Form画到一个Image上,然后再将这个Image打印出来。基本步骤如下:1. Import the BitBlt API function2. Capture the image of the form3. Draw the image in the PrintPage event具体代码如下例所示:[DllImport("gdi32.dll")]private static extern bool BitBlt( IntPtr hdcDest, // handle to destination DC int nXDest, // x-coord of destination upper-left corner int nYDest, // y-coord of destination upper-left corner int nWidth, // width of destination rectangle int nHeight, // height of destination rectangle IntPtr hdcSrc, // handle to source DC int nXSrc, // x-coordinate of source upper-left corner int nYSrc, // y-coordinate of source upper-left corner System.Int32 dwRop // raster operation code );private const Int32 SRCCOPY = 0xCC0020;private Bitmap memImage;private void PrepareImage(){ Graphics graphic = this.CreateGraphics(); Size s = this.Size; memImage = new Bitmap(s.Width, s.Height, graphic); Graphics memGraphic = Graphics.FromImage(memImage); IntPtr dc1 = graphic.GetHdc(); IntPtr dc2 = memGraphic.GetHdc(); BitBlt(dc2, 0, 0, this.ClientRectangle.Width, this.ClientRectangle.Height,dc1, 0, 0, SRCCOPY); graphic.ReleaseHdc(dc1); memGraphic.ReleaseHdc(dc2);}private void button1_Click(object sender, System.EventArgs e){ PrepareImage(); printDocument1.Print();}private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e){ e.Graphics.DrawImage(memImage,0,0);}-微软全球技术中心 VC开发支持本贴子以“现状”提供且没有任何担保,同时也没有授予任何权利。具体事项可参见使用条款(http://support.microsoft.com/directory/worldwide/zh-cn/community/terms_chs.asp)。为了您创建更好的讨论环境,请参加我们的用户满意度调查(http://support.microsoft.com/directory/worldwide/zh-cn/community/survey.asp?key=(S,49854782))。 感谢您使用微软产品您可以用BitBlt API将Form复制到一个Image上,然后再将这个Image打印出来,大致步骤如下:1. Import the BitBlt API function2. Capture the image of the form3. Draw the image in the PrintPage event具体代码如下例所示:[DllImport("gdi32.dll")]private static extern bool BitBlt( IntPtr hdcDest, // handle to destination DC int nXDest, // x-coord of destination upper-left corner int nYDest, // y-coord of destination upper-left corner int nWidth, // width of destination rectangle int nHeight, // height of destination rectangle IntPtr hdcSrc, // handle to source DC int nXSrc, // x-coordinate of source upper-left corner int nYSrc, // y-coordinate of source upper-left corner System.Int32 dwRop // raster operation code );private const Int32 SRCCOPY = 0xCC0020;private Bitmap memImage;private void PrepareImage(){ Graphics graphic = this.CreateGraphics(); Size s = this.Size; memImage = new Bitmap(s.Width, s.Height, graphic); Graphics memGraphic = Graphics.FromImage(memImage); IntPtr dc1 = graphic.GetHdc(); IntPtr dc2 = memGraphic.GetHdc(); BitBlt(dc2, 0, 0, this.ClientRectangle.Width, this.ClientRectangle.Height,dc1, 0, 0, SRCCOPY); graphic.ReleaseHdc(dc1); memGraphic.ReleaseHdc(dc2);}private void button1_Click(object sender, System.EventArgs e){ PrepareImage(); printDocument1.Print();}private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e){ e.Graphics.DrawImage(memImage,0,0);}-微软全球技术中心 VC开发支持本贴子以“现状”提供且没有任何担保,同时也没有授予任何权利。具体事项可参见使用条款(http://support.microsoft.com/directory/worldwide/zh-cn/community/terms_chs.asp)。为了您创建更好的讨论环境,请参加我们的用户满意度调查(http://support.microsoft.com/directory/worldwide/zh-cn/community/survey.asp?key=(S,49854782))。 考研还是继续工作,纠结啊 Request接受值的问题 文件的封装问题 从数据集中取出数组的问题!!! 请教!如何在C#里面调用VB开发的动态连接库文件 .dll ? 问一个关于unicode编码的问题 怎样建立.net2003与sqlserver6.5数据库的连接(在线等) 有人知道如何让线程1运行完毕再继续主线程的方法么? Activator.CreateInstance Exception, Help.... 请教一个简单问题(急) 即然C#執行效率沒Dephi6.0快.功能沒VC強大.哪C#有什麼优點嗎?IL碼有什么优點? 程序出错,请指教 “该文件复制服务检测到一个无效参数。 ”
只有System.Windows.Forms.PrintDialog……
能说清楚点吗?
要使用什么名字空间?
在发生Paint的时候保存里面的Graphics对象
在需要的时候处理(比如输出到打印机或者保存为图片)
创建一个PrintDocument对象,
加上BeginPrint, PrintPage的响应
调用他的void Print()的方法在PrintPage的PrintPageEventArgs的参数中有Graphics的属性,可以通过这个属性绘画。不过我遇到一个问题,Framework的打印组件在WinXP,Win2k中非常稳定,但在Win98,WinME中就经常会出错,特别是PrintPreviewControl的控件
留下你的mail?
請給我一份 [email protected]
thanking of you
[email protected]
2. Capture the image of the form
3. Draw the image in the PrintPage event具体代码如下例所示:[DllImport("gdi32.dll")]
private static extern bool BitBlt(
IntPtr hdcDest, // handle to destination DC
int nXDest, // x-coord of destination upper-left corner
int nYDest, // y-coord of destination upper-left corner
int nWidth, // width of destination rectangle
int nHeight, // height of destination rectangle
IntPtr hdcSrc, // handle to source DC
int nXSrc, // x-coordinate of source upper-left corner
int nYSrc, // y-coordinate of source upper-left corner
System.Int32 dwRop // raster operation code
);private const Int32 SRCCOPY = 0xCC0020;private Bitmap memImage;private void PrepareImage()
{
Graphics graphic = this.CreateGraphics();
Size s = this.Size;
memImage = new Bitmap(s.Width, s.Height, graphic);
Graphics memGraphic = Graphics.FromImage(memImage);
IntPtr dc1 = graphic.GetHdc();
IntPtr dc2 = memGraphic.GetHdc();
BitBlt(dc2, 0, 0, this.ClientRectangle.Width,
this.ClientRectangle.Height,dc1, 0, 0, SRCCOPY);
graphic.ReleaseHdc(dc1);
memGraphic.ReleaseHdc(dc2);
}private void button1_Click(object sender, System.EventArgs e)
{
PrepareImage();
printDocument1.Print();
}private void printDocument1_PrintPage(object sender,
System.Drawing.Printing.PrintPageEventArgs e)
{
e.Graphics.DrawImage(memImage,0,0);
}
-微软全球技术中心 VC开发支持本贴子以“现状”提供且没有任何担保,同时也没有授予任何权利。具体事项可参见使用条款(http://support.microsoft.com/directory/worldwide/zh-cn/community/terms_chs.asp)。为了您创建更好的讨论环境,请参加我们的用户满意度调查(http://support.microsoft.com/directory/worldwide/zh-cn/community/survey.asp?key=(S,49854782))。
2. Capture the image of the form
3. Draw the image in the PrintPage event具体代码如下例所示:[DllImport("gdi32.dll")]
private static extern bool BitBlt(
IntPtr hdcDest, // handle to destination DC
int nXDest, // x-coord of destination upper-left corner
int nYDest, // y-coord of destination upper-left corner
int nWidth, // width of destination rectangle
int nHeight, // height of destination rectangle
IntPtr hdcSrc, // handle to source DC
int nXSrc, // x-coordinate of source upper-left corner
int nYSrc, // y-coordinate of source upper-left corner
System.Int32 dwRop // raster operation code
);private const Int32 SRCCOPY = 0xCC0020;private Bitmap memImage;private void PrepareImage()
{
Graphics graphic = this.CreateGraphics();
Size s = this.Size;
memImage = new Bitmap(s.Width, s.Height, graphic);
Graphics memGraphic = Graphics.FromImage(memImage);
IntPtr dc1 = graphic.GetHdc();
IntPtr dc2 = memGraphic.GetHdc();
BitBlt(dc2, 0, 0, this.ClientRectangle.Width,
this.ClientRectangle.Height,dc1, 0, 0, SRCCOPY);
graphic.ReleaseHdc(dc1);
memGraphic.ReleaseHdc(dc2);
}private void button1_Click(object sender, System.EventArgs e)
{
PrepareImage();
printDocument1.Print();
}private void printDocument1_PrintPage(object sender,
System.Drawing.Printing.PrintPageEventArgs e)
{
e.Graphics.DrawImage(memImage,0,0);
}
-微软全球技术中心 VC开发支持本贴子以“现状”提供且没有任何担保,同时也没有授予任何权利。具体事项可参见使用条款(http://support.microsoft.com/directory/worldwide/zh-cn/community/terms_chs.asp)。为了您创建更好的讨论环境,请参加我们的用户满意度调查(http://support.microsoft.com/directory/worldwide/zh-cn/community/survey.asp?key=(S,49854782))。