?? frm_billpreview.frm
字號:
VERSION 5.00
Begin VB.Form frm_BillPreView
Caption = "打印預(yù)覽"
ClientHeight = 6915
ClientLeft = 60
ClientTop = 345
ClientWidth = 10215
Icon = "frm_BillPreView.frx":0000
LinkTopic = "Form2"
LockControls = -1 'True
ScaleHeight = 6915
ScaleWidth = 10215
StartUpPosition = 1 '所有者中心
WindowState = 2 'Maximized
Begin VB.CommandButton cmdPageFirst
Height = 330
Left = 2655
Picture = "frm_BillPreView.frx":0742
Style = 1 'Graphical
TabIndex = 10
ToolTipText = "第一頁"
Top = 45
Width = 735
End
Begin VB.CommandButton cmdPageLast
Height = 330
Left = 3420
Picture = "frm_BillPreView.frx":0A85
Style = 1 'Graphical
TabIndex = 9
ToolTipText = "最后一頁"
Top = 45
Width = 735
End
Begin VB.CommandButton cmdPageDown
Height = 330
Left = 4185
Picture = "frm_BillPreView.frx":0DC8
Style = 1 'Graphical
TabIndex = 8
ToolTipText = "后一頁"
Top = 45
Width = 735
End
Begin VB.CommandButton cmdPageUp
Height = 330
Left = 1890
Picture = "frm_BillPreView.frx":110B
Style = 1 'Graphical
TabIndex = 7
ToolTipText = "前一頁"
Top = 45
Width = 735
End
Begin VB.CommandButton cmdPrint
Height = 330
Left = 90
Picture = "frm_BillPreView.frx":144E
Style = 1 'Graphical
TabIndex = 5
ToolTipText = "打印"
Top = 45
Width = 735
End
Begin VB.CommandButton cmdClose
Height = 330
Left = 900
Picture = "frm_BillPreView.frx":1791
Style = 1 'Graphical
TabIndex = 4
ToolTipText = "關(guān)閉"
Top = 45
Width = 735
End
Begin VB.PictureBox pictView
BackColor = &H8000000C&
BorderStyle = 0 'None
Height = 3390
Left = 45
ScaleHeight = 3390
ScaleWidth = 8565
TabIndex = 0
Top = 450
Width = 8565
Begin VB.HScrollBar HS
Height = 285
LargeChange = 1000
Left = 0
SmallChange = 100
TabIndex = 3
Top = 2925
Width = 8250
End
Begin VB.VScrollBar VS
Height = 3165
LargeChange = 1000
Left = 8235
SmallChange = 100
TabIndex = 2
Top = 0
Width = 285
End
Begin VB.PictureBox pictMain
AutoRedraw = -1 'True
BackColor = &H80000005&
BorderStyle = 0 'None
Height = 2355
Left = 630
MouseIcon = "frm_BillPreView.frx":1AD3
MousePointer = 99 'Custom
ScaleHeight = 2355
ScaleWidth = 4920
TabIndex = 1
Top = 225
Width = 4920
End
End
Begin VB.Label labPage
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "第 1 頁 共 1 頁"
BeginProperty Font
Name = "宋體"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H8000000D&
Height = 180
Left = 5130
TabIndex = 6
Top = 120
Width = 1530
End
End
Attribute VB_Name = "frm_BillPreView"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Const PictSet = 100
'頁面高寬
Dim mHeight As Double, mWidth As Double
'頁邊距
Dim mSLeft As Double, mSRight As Double, mSUp As Double, mSDown As Double
'True = 放大顯示,F(xiàn)alse = 縮小顯示
Dim ViewMod As Boolean
'觀察點
Dim ViewX As Double, ViewY As Double
'比例
Dim mHWScal As Double
Dim mPage As Integer, mPages As Integer
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub cmdPageDown_Click()
If mPage < mPages Then mPage = mPage + 1: Call PViewRep
End Sub
Private Sub cmdPageFirst_Click()
mPage = 1: Call PViewRep
End Sub
Private Sub cmdPageLast_Click()
mPage = mPages: Call PViewRep
End Sub
Private Sub cmdPageUp_Click()
If mPage > 1 Then mPage = mPage - 1: Call PViewRep
End Sub
Private Sub cmdPrint_Click()
ViewMod = True
Call BillPrint
End Sub
Public Sub PageSetup()
Dim i As Integer
pictMain.Cls
'設(shè)置頁面參數(shù)
If mLandScape = 1 Then
mHeight = mPageWidth: mWidth = mPageHeight
Else
mHeight = mPageHeight: mWidth = mPageWidth
End If
'設(shè)置頁面邊距
mSLeft = mPageLeft: mSRight = mPageRight: mSUp = mPageUp: mSDown = mPageDown
'頁面高寬比例
mHWScal = mHeight / mWidth
pictMain.Left = PictSet: pictMain.Top = PictSet
ViewX = 0: ViewY = 0
mPage = 1: mPages = mTotalPage
ViewMod = True: Call PViewRep
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Set frm_BillPreView = Nothing
End Sub
Private Sub Form_Resize()
On Error Resume Next
pictView.Move pictView.Left, pictView.Top, Me.Width - 2 * pictView.Left - 100, Me.Height - pictView.Top - pictView.Left - 400
End Sub
Private Sub Form_Unload(Cancel As Integer)
' Set mrecBill = Nothing
' Set mrecPrint = Nothing
' Set mrecLine = Nothing
' Set mrecText = Nothing
End Sub
Private Sub HS_Change()
pictMain.Move PictSet - HS.Value
End Sub
Private Sub pictMain_Click()
ViewMod = Not ViewMod: Call PViewRep
End Sub
Private Sub pictMain_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
ViewX = X: ViewY = Y
End Sub
Private Sub VS_Change()
pictMain.Move pictMain.Left, PictSet - VS.Value
End Sub
Private Sub pictView_Resize()
Dim mX, mY As Single
On Error Resume Next
HS.Move 0, pictView.Height - HS.Height, pictView.Width - VS.Width
VS.Move pictView.Width - VS.Width, 0, VS.Width, pictView.Height - HS.Height
If pictMain.Width > pictView.Width Then
pictMain.Left = PictSet
HS.Min = 0: HS.Max = pictMain.Width - VS.Left + 2 * PictSet
mX = ViewX - pictView.Width / 2
If mX < HS.Min Then mX = HS.Min
If mX > HS.Max Then mX = HS.Max
HS.Value = 0: HS.Value = mX
HS.Visible = True
Else
pictMain.Left = (pictView.Width - pictMain.Width) / 2
HS.Visible = False
End If
If pictMain.Height > pictView.Height Then
pictMain.Top = PictSet
VS.Min = 0: VS.Max = pictMain.Height - HS.Top + 2 * PictSet
mY = ViewY - pictView.Height / 2
If mY < VS.Min Then mY = VS.Min
If mY > VS.Max Then mY = VS.Max
VS.Value = 0: VS.Value = mY
VS.Visible = True
Else
pictMain.Top = (pictView.Height - pictMain.Height) / 2
VS.Visible = False
End If
End Sub
'設(shè)置頁面
Private Function PViewPage()
Dim CHeight, CWidth As Long
If ViewMod = True Then
'實際大小顯示
CHeight = mHeight: CWidth = mWidth
Else
'適應(yīng)窗口顯示
If (pictView.Height - 2 * PictSet) / (pictView.Width - 2 * PictSet) < mHWScal Then
'限制高度
CHeight = pictView.Height - 2 * PictSet: CWidth = CHeight / mHWScal
Else
'限制寬度
CWidth = pictView.Width - 2 * PictSet: CHeight = CWidth * mHWScal
End If
End If
pictMain.Height = CHeight: pictMain.Width = CWidth
'映射坐標(biāo)到真實大小
pictMain.ScaleHeight = mHeight: pictMain.ScaleWidth = mWidth
'重畫
Call pictView_Resize
'縮放比例
mPageScale = pictMain.Height / pictMain.ScaleHeight
End Function
'顯示一頁
Private Function PViewRep()
labPage = "第 " & mPage & " 頁/共 " & mPages & " 頁"
Me.MousePointer = vbHourglass
pictMain.Cls
Call PViewPage
Call ShowBillData(mPage)
pictMain.Visible = True
Me.MousePointer = vbDefault
End Function
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -