C#打印Panel问题
问题,我的panel设置和A4纸一样大小,但是显示器放不下,所以做了滚动条,但是打印时只能打出显示器显示的部分,超出显示器的部分就打不上,怎么办????
private void vistaButton1_Click(object sender, EventArgs e)
{
CaptureScreen();
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
PrintPreviewDialog cppd = new PrintPreviewDialog();
cppd.Document = pd;
cppd.ShowDialog();
}
void pd_PrintPage(object sender, PrintPageEventArgs e)
{
e.Graphics.DrawImage(memoryImage, 0, 0);
}
[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.panel1.CreateGraphics();//创建的是整个panel
Size s = this.panel1.Size;//取panel大小
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.panel1.ClientRectangle.Width, this.panel1.ClientRectangle.Height, dc1, 0, 0, 13369376);
mygraphics.ReleaseHdc(dc1);
memoryGraphics.ReleaseHdc(dc2);
}
private void vistaButton1_Click(object sender, EventArgs e)
{
CaptureScreen();
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
PrintPreviewDialog cppd = new PrintPreviewDialog();
cppd.Document = pd;
cppd.ShowDialog();
}
void pd_PrintPage(object sender, PrintPageEventArgs e)
{
e.Graphics.DrawImage(memoryImage, 0, 0);
}
[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.panel1.CreateGraphics();//创建的是整个panel
Size s = this.panel1.Size;//取panel大小
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.panel1.ClientRectangle.Width, this.panel1.ClientRectangle.Height, dc1, 0, 0, 13369376);
mygraphics.ReleaseHdc(dc1);
memoryGraphics.ReleaseHdc(dc2);
}
...全文
相关推荐
c# 实现对panel的打印
### C# 中实现 Panel 的打印功能在C# WinForms应用程序开发中,有时我们需要将某个 `Panel` 控件中的内容打印出来。
C# Winform医院挂号管理系统开发实践:从数据库设计到并发控制
在桌面端管理系统的开发中,C/S架构凭借其局域网响应速度和离线容错能力,仍是医院、诊所等场所的务实选择。Winform作为成熟的桌面开发框架,配合关系型数据库,能够高效构建业务逻辑密集的行业应用。开发这类系统时,数据库表结构的设计决定了业务扩展的边界,而事务与锁机制则是保证数据一致性的核心。通过合理的排班表、号源表与挂号记录表联动,结合存储过程封装原子操作,可有效应对超号、退号回补等真实场景。医院挂号管理系统的实践不仅覆盖CRUD操作,更涉及并发控制、权限管理、报表统计与接口对接等工程化能力。本文以C#与W
C#源码报表打印ShowCReport
C#源码报表打印ShowCReport是一个基于C#语言开发的报表打印功能实现项目,其核心目标是为Windows桌面应用程序提供一套轻量、稳定、可扩展的报表展示与物理打印支持机制。
DotNetBar条码打印.7z
开发人员需要考虑如何合理布局控件,确保用户能够方便地输入条形码数据,选择打印选项,并触发打印过程。5. **编程实践**: 在实际编程中,开发者需要使用C#或VB.NET等.NET语言来编写代码。
ArcGIS_Engine_C#实例开发教程
PageLayoutControl**- **功能**: 布局设计,用于地图的打印输出等。


