📄 frmqueryprint.frm
字号:
_ExtentY = 582
ButtonWidth = 609
ButtonHeight = 582
Style = 1
ImageList = "imgWB"
HotImageList = "imgClr"
_Version = 393216
BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628}
NumButtons = 16
BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628}
Style = 3
EndProperty
BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628}
Enabled = 0 'False
Key = "first"
Object.ToolTipText = "第一页"
ImageKey = "first"
EndProperty
BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628}
Enabled = 0 'False
Key = "previous"
Object.ToolTipText = "前一页"
ImageKey = "previous"
EndProperty
BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628}
EndProperty
BeginProperty Button5 {66833FEA-8583-11D1-B16A-00C0F0283628}
EndProperty
BeginProperty Button6 {66833FEA-8583-11D1-B16A-00C0F0283628}
EndProperty
BeginProperty Button7 {66833FEA-8583-11D1-B16A-00C0F0283628}
EndProperty
BeginProperty Button8 {66833FEA-8583-11D1-B16A-00C0F0283628}
Key = "next"
Object.ToolTipText = "下一页"
ImageKey = "next"
EndProperty
BeginProperty Button9 {66833FEA-8583-11D1-B16A-00C0F0283628}
Key = "last"
Object.ToolTipText = "最后一页"
ImageKey = "last"
EndProperty
BeginProperty Button10 {66833FEA-8583-11D1-B16A-00C0F0283628}
Style = 3
EndProperty
BeginProperty Button11 {66833FEA-8583-11D1-B16A-00C0F0283628}
Key = "zoomout"
Object.ToolTipText = "比例缩小"
ImageKey = "zoomout"
EndProperty
BeginProperty Button12 {66833FEA-8583-11D1-B16A-00C0F0283628}
Key = "zoomin"
Object.ToolTipText = "比例放大"
ImageKey = "zoomin"
EndProperty
BeginProperty Button13 {66833FEA-8583-11D1-B16A-00C0F0283628}
Style = 3
EndProperty
BeginProperty Button14 {66833FEA-8583-11D1-B16A-00C0F0283628}
EndProperty
BeginProperty Button15 {66833FEA-8583-11D1-B16A-00C0F0283628}
EndProperty
BeginProperty Button16 {66833FEA-8583-11D1-B16A-00C0F0283628}
Style = 3
EndProperty
EndProperty
Begin VB.TextBox txtPart
Alignment = 2 'Center
Height = 285
Left = 1560
TabIndex = 11
Text = "1"
ToolTipText = "跳转页数"
Top = 20
Width = 645
End
Begin VB.ComboBox cboScale
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 300
ItemData = "frmQueryPrint.frx":7570
Left = 3840
List = "frmQueryPrint.frx":7572
Style = 2 'Dropdown List
TabIndex = 5
ToolTipText = "缩放比例"
Top = 0
Width = 1005
End
Begin VB.TextBox txtPage
Alignment = 2 'Center
Height = 285
Left = 825
TabIndex = 4
Text = "1"
ToolTipText = "跳转页数"
Top = 20
Width = 645
End
End
Begin MSComctlLib.Toolbar tbPrint
Height = 330
Left = 30
TabIndex = 2
Top = 30
Width = 2445
_ExtentX = 4313
_ExtentY = 582
ButtonWidth = 1958
ButtonHeight = 582
Style = 1
TextAlignment = 1
ImageList = "imgWB"
HotImageList = "imgClr"
_Version = 393216
BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628}
NumButtons = 5
BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "打印(&P)"
Key = "print"
Object.ToolTipText = "输出到打印机"
ImageKey = "print"
EndProperty
BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628}
Object.Visible = 0 'False
ImageKey = "export"
Style = 3
EndProperty
BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628}
Object.Visible = 0 'False
Caption = "导出(&E)"
Key = "export"
Object.ToolTipText = "报表导出"
ImageKey = "export"
EndProperty
BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628}
Style = 3
EndProperty
BeginProperty Button5 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "设置(&O)"
Key = "set"
ImageKey = "set"
EndProperty
EndProperty
End
End
Begin VB.Menu mnu_pop
Caption = "弹出式菜单"
Visible = 0 'False
Begin VB.Menu mnu_print
Caption = ">> 输出到打印机..."
End
Begin VB.Menu ln1
Caption = "-"
End
Begin VB.Menu mnu_zoomin
Caption = "+ 放大"
End
Begin VB.Menu mnu_zoomout
Caption = "- 缩小"
End
Begin VB.Menu mnu_zoomactual
Caption = " 实际大小"
End
Begin VB.Menu mnu_zoombest
Caption = " 适合大小"
End
Begin VB.Menu ln2
Caption = "-"
End
Begin VB.Menu mnu_info
Caption = " 信息查看"
End
Begin VB.Menu ln3
Caption = "-"
End
Begin VB.Menu mnu_first
Caption = "|← 跳转到最前页"
End
Begin VB.Menu mnu_previous
Caption = "← 跳转到上一页"
End
Begin VB.Menu mnu_next
Caption = "→ 跳转到下一页"
End
Begin VB.Menu mnu_last
Caption = "→| 跳转到最后一页"
End
Begin VB.Menu ln4
Caption = "-"
End
Begin VB.Menu mnu_exit
Caption = "× 退出打印预览"
End
End
End
Attribute VB_Name = "frmQueryPrint"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'打印数据网格控件 黄敬东
Option Explicit
Dim myInfo As PrintInfo '记录打印表头的信息
Dim picH As Long, picW As Long 'picture控件的父容器的长和宽
Dim oldV As Long, oldH As Long '垂直和水平滚动条的原来的位置
Dim oldIndex As Integer '显示比例下拉框原来的被选项Index值
Dim iFCount As Integer '当前报表的总列数
Dim iICount As Integer '双层列头结构,上层的列数
Dim rowNum As Integer '每页的行数
Dim rowCount As Integer '总共的记录数
Dim colInfo() As PrintInfo '记录打印记录的信息
Dim pageCount As Integer '总页数
Dim pageNum As Integer '当前页码
Dim lHeight As Integer '记录已打印区域的高度
Dim intReportWidth As Integer '报表的总宽度
Dim intOldScaleMode As Integer '记录父窗口原来的度量单位
Dim intCurrentWidth As Integer '当前打印页的宽度
Dim arrCol(1 To 99, 1 To 4) As Integer '对于过宽报表,记录分页的信息
'第一维为总数页,最多可分成99页
'第二维为每页的起始字段、结束字段、当前页的宽度以及以前页的宽度和
Dim intPartIndex, intPartCount As Integer '对于过宽报表,当前打印的页号和总共分成的页数
Dim bCancle As Boolean '打印被取消
'***********************************************************************************
' 重新设置翻页按钮的Eanbled的值
'***********************************************************************************
Private Sub SetMoveButton()
tbTool.Buttons("first").Enabled = True
tbTool.Buttons("previous").Enabled = True
tbTool.Buttons("next").Enabled = True
tbTool.Buttons("last").Enabled = True
If pageNum = 1 And intPartIndex = 1 Then
tbTool.Buttons("first").Enabled = False
tbTool.Buttons("previous").Enabled = False
End If
If pageNum = pageCount And intPartIndex = intPartCount Then
tbTool.Buttons("next").Enabled = False
tbTool.Buttons("last").Enabled = False
End If
txtPage.Text = CStr(pageNum) & "/" & CStr(pageCount)
txtPart.Text = CStr(intPartIndex) & "/" & CStr(intPartCount)
End Sub
'***********************************************************************************
' 重新设置控件picPreviewtop,left值
' 重新设置滚动条的height,width级Enabled 或Left,top值
'***********************************************************************************
Private Sub ResizePic()
'根据打印机纸张的设置和设置picPreview的高和宽及picPreview模拟显示的高和宽
picPreview.Height = Printer.Height * iPercent / 100
picPreview.Width = Printer.Width * iPercent / 100
picPreview.ScaleHeight = Printer.ScaleHeight
picPreview.ScaleWidth = Printer.ScaleWidth
'判断picpreview的高度是否大于picH,是则使用垂直滚动条
If picPreview.Height > picH Then
vsl.Visible = True
vsl.Value = 0
vsl.Max = (picPreview.Height - picH) / IIf((picPreview.Height - picH) > 32767, 10, 1)
vsl.LargeChange = vsl.Max / 10
vsl.SmallChange = vsl.Max / 100
Else
vsl.Visible = False
End If
'判断picpreview的宽度是否大于picW,是则使用水平滚动条
If picPreview.Width > picW Then
hsl.Visible = True
hsl.Value = 0
hsl.Max = (picPreview.Width - picW) / IIf((picPreview.Width - picW) > 32767, 10, 1)
hsl.LargeChange = hsl.Max / 10
hsl.SmallChange = hsl.Max / 100
Else
hsl.Visible = False
End If
picBot.Visible = hsl.Visible
'滚动条定位
picBot.Left = 0
picBot.Width = picBack.Width
picBot.Top = picBack.Height - picBot.Height
hsl.Left = 0
hsl.Top = picBack.Height - hsl.Height - 70
hsl.Width = picBack.Width - 60 - IIf(vsl.Visible, vsl.Width, 0)
vsl.Top = 0
vsl.Left = picBack.Width - vsl.Width - 70
vsl.Height = picBack.Height - 50 - IIf(hsl.Visible, hsl.Height, 0)
'picPreview的高、宽和其父容器的高、宽的关系来设置picPreviw的top、left的值
If picPreview.Width < picBack.Width - 60 - IIf(vsl.Visible, vsl.Width, 0) Then
picPreview.Left = ((picBack.Width - 60 - IIf(vsl.Visible, vsl.Width, 0)) - picPreview.Width) / 2
Else
picPreview.Left = 40
End If
If picPreview.Height < (picBack.Height - 50 - IIf(hsl.Visible, hsl.Height, 0)) Then
picPreview.Top = ((picBack.Height - 50 - IIf(hsl.Visible, hsl.Height, 0)) - picPreview.Height) / 2
Else
picPreview.Top = 80
End If
Call DrawPage
End Sub
'***********************************************
'画页面的背景
'***********************************************
Private Sub DrawPage()
picBack.Cls
'/*画页面的线
picBack.Line (picPreview.Left - 10, picPreview.Top - 10)-Step(picPreview.Width, -5), &H80000010, BF
picBack.Line (picPreview.Left - 10, picPreview.Top - 10)-Step(-5, picPreview.Height), &H80000010, BF
picBack.Line (picPreview.Left + 50, picPreview.Top + picPreview.Height)-Step(picPreview.Width, 50), vbBlack, BF
picBack.Line (picPreview.Left + picPreview.Width, picPreview.Top + 50)-Step(50, picPreview.Height), vbBlack, BF
End Sub
'***********************************************************************************
' 分析报表的页面信息
'***********************************************************************************
Private Sub PageAnalyze()
Dim i As Integer, j As Integer, intCurX As Long
' 计算当前页数和每页的记录数
rowCount = rstReport.RecordCount
rowNum = Int((Printer.ScaleHeight - (rectMargin.Top + rectMargin.Bottom _
+ iHeadHeight + iFootHeight + intHeaderHeight)) / intRowHeight) '15为页头的高度
pageCount = rowCount \ rowNum + IIf((rowCount Mod rowNum) = 0, 0, 1)
' 分析分页情况
intPartIndex = 1
intCurX = 0
intCurrentWidth = 0
arrCol(1, 1) = 0
j = 1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -