如何显示打印窗体printDialog? System.Windows.Forms.PrintDialog操作事例:http://www.c-sharpcorner.com/Graphics/W2FormMG.asp 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 调用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 DCint nXDest, // x-coord of destination upper-left cornerint nYDest, // y-coord of destination upper-left cornerint nWidth, // width of destination rectangleint nHeight, // height of destination rectangleIntPtr hdcSrc, // handle to source DCint nXSrc, // x-coordinate of source upper-left cornerint nYSrc, // y-coordinate of source upper-left cornerSystem.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);}用这个方法打印了,但是打印过程中弹出了一个正在打印的小对话框,结果把这个也打上了遮住了要打印窗体的一部分。有没有什么办法让他不弹出对话框啊? 求教 有木有像visual studio错误列表 的控件啊?? 删除A标签操作 过程或函数 需要参数 但未提供该参数 如何在用逗号分隔的字符串中添加多个字符 实际开发当中遇到的父子关系问题,高手指点。! 高手赐教 , c# 如何实现 dll 全局变量. 好奇怪的command问题吖 怎样用System.Data.Odbc去调用oracle的既有输入参数又有输出参数的存储过程,我的代码如下 求助 用C#做电子邮件 請問高手, C#中用哪一種功能(方法)取代了以前宏的功能(方法)?
调用BitBlt API将整个Form画到一个Image上,然后再将这个Image打印出来。基本步骤如下:1. Import the BitBlt API function
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);
}用这个方法打印了,但是打印过程中弹出了一个正在打印的小对话框,结果把这个也打上了
遮住了要打印窗体的一部分。
有没有什么办法让他不弹出对话框啊?