首页 > 开发 > 综合 > 正文

C#中如何对当前窗体进行打印预览

2024-07-21 02:19:26
字体:
来源:转载
供稿:网友
[system.runtime.interopservices.dllimport("gdi32.dll")]
public static extern long bitblt (intptr hdcdest, int nxdest, int nydest, int nwidth, int nheight, intptr hdcsrc, int nxsrc, int nysrc, int dwrop);
private bitmap memoryimage;
private void capturescreen()
{
graphics mygraphics = this.creategraphics();
size s = this.size;
memoryimage = new bitmap(s.width, s.height, mygraphics);
graphics memorygraphics = graphics.fromimage(memoryimage);
intptr dc1 = mygraphics.gethdc();
intptr dc2 = memorygraphics.gethdc();
bitblt(dc2, 0, 0, this.clientrectangle.width, this.clientrectangle.height, dc1, 0, 0, 13369376);
mygraphics.releasehdc(dc1);
memorygraphics.releasehdc(dc2);
}
private void printdocument1_printpage(system.object sender, system.drawing.printing.printpageeventargs e)
{
e.graphics.drawimage(memoryimage, 0, 0);
}
private void printbutton_click(system.object sender, system.eventargs e)
{
capturescreen();
printpreviewdialog1.show();
}

商业源码热门下载www.html.org.cn

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表