当前位置:编程学习 > VB >>

关于数据报表的打印设置

 

 

数据报表(DataReport)是VB6新增功能之一。用过它的朋友对这个设计器可以说是既爱且恨。尽管它功能强大,但却有个非常致命的缺点:无法在设计环境中改变纸张大小及走向。即使你在程序中使用Printer对象改变纸张大小及打印走向,也解决不了问题。对于非A4纸的报表或是横向打印的报表,连报表预览都不行。

 

问题的原因是:DR基于系统默认的打印设置创建自己的内部设备环境。而这个设备环境是没有向外界展现的。DR的内部设备环境与VB的Printer对象的内部设备环境是完全不同的,因此改变打印机对象的属性对DR一点效果也没有。

 

解决这个问题的笨办法是,在预览或打印时改变系统默认打印机的设置。使用这个方法连自己都会觉得麻烦,更何况是你的用户。没办法,只能通过代码强行改变系统默认打印机的设置来解决。将下面的代码放入一个模块中:

 

Option Explicit

 

Public Enum PrinterOrientationConstants

        OrientPortrait = 1

        OrientLandscape = 2

End Enum

Private Type DEVMODE

        dmDeviceName As String * 32

        dmSpecVersion As Integer

        dmDriverVersion As Integer

        dmSize As Integer

        dmDriverExtra As Integer

        dmFields As Long

        dmOrientation As Integer

        dmPaperSize As Integer

        dmPaperLength As Integer

        dmPaperWidth As Integer

        dmScale As Integer

        dmCopies As Integer

        dmDefaultSource As Integer

        dmPrintQuality As Integer

        dmColor As Integer

        dmDuplex As Integer

        dmYResolution As Integer

        dmTTOption As Integer

        dmCollate As Integer

        dmFormName As String * 32

        dmUnusedPadding As Integer

        dmBitsPerPel As Integer

        dmPelsWidth As Long

        dmPelsHeight As Long

        dmDisplayFlags As Long

        dmDisplayFrequency As Long

End Type

Private Type PRINTER_DEFAULTS

        pDataType As String

        pDevMode As Long

        DesiredAccess As Long

End Type

Private Type PRINTER_INFO_2

        pServerName As Long

        pPrinterName As Long

        pShareName As Long

        pPortName As Long

        pDriverName As Long

        pComment As Long

补充:软件开发 , Vb ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,