码迷,mamicode.com
首页 > Windows程序 > 详细

C# 打印窗口

时间:2019-11-19 18:51:13      阅读:156      评论:0      收藏:0      [点我收藏+]

标签:rom   打印   width   val   screen   graphic   int   click   from   

private void cmd_prn_Click(object sender, EventArgs e)
{
if (printDoc.PrinterSettings.IsValid == false) return;
Graphics myGraphics = this.CreateGraphics();
Size s = this.Size;
memoryImage = new Bitmap(s.Width, s.Height, myGraphics);
Graphics memoryGraphics = Graphics.FromImage(memoryImage);
memoryGraphics.CopyFromScreen(this.Location.X, this.Location.Y, 0, 0, s);

printDoc.Print();
}

 

 printDoc_PrintPage事件添加:

private void printDoc_PrintPage(object sender, PrintPageEventArgs e)
{
e.Graphics.DrawImage(memoryImage, 0, 0);
}

C# 打印窗口

标签:rom   打印   width   val   screen   graphic   int   click   from   

原文地址:https://www.cnblogs.com/-jwj/p/11891327.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!