📄 frmgridprint.frm
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form frmGridPrint
BorderStyle = 3 'Fixed Dialog
Caption = "打印预览"
ClientHeight = 8595
ClientLeft = 240
ClientTop = 330
ClientWidth = 11880
ControlBox = 0 'False
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
Moveable = 0 'False
ScaleHeight = 8595
ScaleWidth = 11880
ShowInTaskbar = 0 'False
StartUpPosition = 1 'CenterOwner
Begin MSComctlLib.Toolbar Toolbar1
Align = 1 'Align Top
Height = 615
Left = 0
TabIndex = 8
Top = 0
Width = 11880
_ExtentX = 20955
_ExtentY = 1085
ButtonWidth = 609
ButtonHeight = 926
AllowCustomize = 0 'False
Appearance = 1
_Version = 393216
BorderStyle = 1
Begin VB.TextBox txtPageNum
Alignment = 1 'Right Justify
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 310
Left = 5420
TabIndex = 4
Top = 150
Width = 615
End
Begin VB.CommandButton cmdGoTo
Caption = "跳至"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 4800
TabIndex = 3
Top = 120
Width = 615
End
Begin VB.CommandButton cmdAbout
Caption = "关于"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 10560
TabIndex = 13
Top = 120
Width = 1215
End
Begin VB.CommandButton cmdClose
Caption = "退出"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 9120
TabIndex = 7
Top = 120
Width = 1335
End
Begin VB.CommandButton cmdOption
Caption = "页面设置"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 7680
TabIndex = 6
Top = 120
Width = 1335
End
Begin VB.CommandButton cmdPrint
Caption = "打印"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 6120
TabIndex = 5
Top = 120
Width = 1455
End
Begin VB.CommandButton cmdNext
Caption = "后一页"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 3360
TabIndex = 2
Top = 120
Width = 1335
End
Begin VB.CommandButton cmdPrevious
Caption = "前一页"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 1920
TabIndex = 1
Top = 120
Width = 1335
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
Left = 120
Style = 2 'Dropdown List
TabIndex = 0
Top = 120
Width = 1455
End
End
Begin VB.VScrollBar vsl
Enabled = 0 'False
Height = 7725
Left = 11640
TabIndex = 11
Top = 600
Width = 255
End
Begin VB.Frame fraPic
BorderStyle = 0 'None
Height = 7725
Left = 0
TabIndex = 10
Top = 600
Width = 11625
Begin VB.PictureBox picPreview
Appearance = 0 'Flat
AutoRedraw = -1 'True
BackColor = &H80000005&
BeginProperty Font
Name = "宋体"
Size = 8.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 6675
Left = 1320
ScaleHeight = 117.211
ScaleMode = 0 'User
ScaleWidth = 175.419
TabIndex = 12
Top = 720
Width = 9975
End
End
Begin VB.HScrollBar hsl
Enabled = 0 'False
Height = 255
Left = 0
TabIndex = 9
Top = 8350
Width = 11625
End
End
Attribute VB_Name = "frmGridPrint"
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 '对于过宽报表,当前打印的页号和总共分成的页数
'***********************************************************************************
' 重新设置控件picPreviewtop,left值
' 重新设置滚动条的height,width级Enabled 或Left,top值
'***********************************************************************************
Private Sub ResizePic()
'------判断picpreview的高度是否大于picH,是则使用垂直滚动条
If picPreview.Height > picH Then
vsl.Enabled = 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.Enabled = False
End If
'------判断picpreview的宽度是否大于picW,是则使用水平滚动条
If picPreview.Width > picW Then
hsl.Enabled = 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.Enabled = False
End If
'------picPreview的高、宽和其父容器的高、宽的关系来设置picPreviw的top、left的值
If picPreview.Width < fraPic.Width Then
picPreview.Left = (fraPic.Width - picPreview.Width) / 2
Else
picPreview.Left = 40
End If
If picPreview.Height < fraPic.Height Then
picPreview.Top = (fraPic.Height - picPreview.Height) / 2
Else
picPreview.Top = 120
End If
End Sub
'***********************************************************************************
' 分析报表的页面信息
'***********************************************************************************
Private Sub PageAnalyze()
Dim i As Integer, j As Integer, intCurX As Long
' 计算当前页数和每页的记录数
rowCount = rstReport.RecordCount
rowNum = Int((Printer.ScaleHeight - (topY + bottomY + 15 + intHeaderHeight)) / intRowHeight)
pageCount = rowCount \ rowNum + IIf((rowCount Mod rowNum) = 0, 0, 1)
' 分析分页情况
intPartIndex = 1
intCurX = 0
intCurrentWidth = 0
arrCol(1, 1) = 0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -