www.pudn.com > prit.rar > frmPrnPrv.frm
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Object = "{C5235EE7-5529-11DA-BCFF-AF5533AF6218}#1.0#0"; "PRINTPREVIEW.OCX"
Begin VB.Form frmPrnPrv
Caption = "打印预览 胡为平版权所有,huweiping0068@sina.com"
ClientHeight = 6795
ClientLeft = 60
ClientTop = 345
ClientWidth = 11220
Icon = "frmPrnPrv.frx":0000
LinkTopic = "Form2"
LockControls = -1 'True
MinButton = 0 'False
ScaleHeight = 6795
ScaleWidth = 11220
StartUpPosition = 2 '屏幕中心
WindowState = 2 'Maximized
Begin printerAndpreview.HuPrintPreview HuPrintPreview1
Height = 4905
Left = 270
TabIndex = 11
Top = 570
Width = 6570
_ExtentX = 11589
_ExtentY = 8652
Rows = 3
Cols = 3
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BeginProperty FontFixed {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin MSComDlg.CommonDialog cdlprnPrv
Left = 3720
Top = 4260
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.PictureBox ToolBar
Align = 1 'Align Top
BackColor = &H80000000&
BorderStyle = 0 'None
Height = 465
Left = 0
ScaleHeight = 465
ScaleWidth = 11220
TabIndex = 0
Top = 0
Width = 11220
Begin VB.CommandButton cmd
Height = 390
Index = 7
Left = 3435
Picture = "frmPrnPrv.frx":030A
Style = 1 'Graphical
TabIndex = 10
ToolTipText = "退出"
Top = 15
UseMaskColor = -1 'True
Width = 435
End
Begin VB.ComboBox cmbFanXiang
Height = 300
Left = 3945
Style = 2 'Dropdown List
TabIndex = 9
Top = 60
Width = 1455
End
Begin VB.CommandButton cmd
Caption = "设置"
Height = 360
Index = 2
Left = 630
MaskColor = &H00FFFFFF&
Picture = "frmPrnPrv.frx":0614
TabIndex = 7
ToolTipText = "打印机设置"
Top = 30
UseMaskColor = -1 'True
Width = 570
End
Begin VB.CommandButton cmd
Caption = "下一页"
Height = 390
Index = 4
Left = 1875
Picture = "frmPrnPrv.frx":0716
TabIndex = 5
ToolTipText = "下一页"
Top = 15
Width = 735
End
Begin VB.CommandButton cmd
Caption = "上一页"
Enabled = 0 'False
Height = 360
Index = 3
Left = 1200
Picture = "frmPrnPrv.frx":0B58
TabIndex = 4
ToolTipText = "上一页"
Top = 30
Width = 675
End
Begin VB.CommandButton cmd
Caption = "打印"
Height = 345
Index = 1
Left = 15
Picture = "frmPrnPrv.frx":0F9A
TabIndex = 3
ToolTipText = "打印"
Top = 30
UseMaskColor = -1 'True
Width = 600
End
Begin VB.CommandButton cmd
Height = 390
Index = 5
Left = 2640
Picture = "frmPrnPrv.frx":109C
Style = 1 'Graphical
TabIndex = 2
ToolTipText = "放大"
Top = 15
UseMaskColor = -1 'True
Width = 375
End
Begin VB.CommandButton cmd
Height = 390
Index = 6
Left = 3045
Picture = "frmPrnPrv.frx":119E
Style = 1 'Graphical
TabIndex = 1
ToolTipText = "缩小"
Top = 15
UseMaskColor = -1 'True
Width = 375
End
Begin VB.Label lblpageCode
Alignment = 2 'Center
Caption = "第1页共1页"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 300
Left = 5445
TabIndex = 8
Top = 75
Width = 1410
End
Begin VB.Label lblInOut
Alignment = 2 'Center
Caption = "预览比例:100%"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 300
Left = 6705
TabIndex = 6
Top = 75
Width = 1830
End
End
End
Attribute VB_Name = "frmPrnPrv"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Public Pages As Integer, CurPage As Integer
Private Sub cmd_Click(Index As Integer)
With HuPrintPreview1
Select Case Index
Case 1: PrnPrint
Case 2: printerSetup
Case 3:
.PageUp
Case 4:
.PageDown
Case 5: .ZoomOut
Case 6: .ZoomIn
Case 7: Unload Me
End Select
End With
End Sub
Private Sub cmbFanXiang_Click()
On Error Resume Next
Dim i As Integer, ps As Integer
Me.MousePointer = 11
i = cmbFanXiang.ListIndex
If i <> Printer.Orientation And i > 0 Then
ps = HuPrintPreview1.Pages
Printer.Orientation = i
HuPrintPreview1.OrientationValue = i
DoEvents
HuPrintPreview1.PrnFresh
cmd(4).Enabled = HuPrintPreview1.Pages > 1
lblpageCode.Caption = "第" & Format(HuPrintPreview1.CurrentPage, "00") & "页共" & Format(HuPrintPreview1.Pages, "00") & "页"
End If
HuPrintPreview1.SetFocus
Me.MousePointer = 0
End Sub
Public Sub PrnPrv_Refresh()
On Error GoTo theError
Printer.PaperSize = vbPRPSA4
If OrientationValue = -1 Then
cmbFanXiang.ListIndex = Printer.Orientation
Else
cmbFanXiang.ListIndex = OrientationValue
End If
HuPrintPreview1.OrientationValue = cmbFanXiang.ListIndex
cmd(4).Enabled = HuPrintPreview1.Pages > 1
lblpageCode.Caption = "第" & Format(HuPrintPreview1.CurrentPage, "0") & "页共" & Format(HuPrintPreview1.Pages, "0") & "页"
Exit Sub
theError:
If Err = 482 Then
MsgBox "(Err:" + Str(Err.Number) + " ) " + "打印机不存在或未准备好! ", vbCritical
Resume Next
Else
Resume Next
End If
End Sub
'Private Sub Form_Activate()
'lblpageCode.Caption = "第" & Format(HuPrintPreview1.CurrentPage, "0") & "页共" & Format(HuPrintPreview1.Pages, "0") & "页"
'
'End Sub
Private Sub Form_Load()
Dim i As Integer
ToolBar.Move 0, 0, Width
cmbFanXiang.Clear
cmbFanXiang.AddItem "无打印机或打印方向未设定"
cmbFanXiang.AddItem "纵向打印"
cmbFanXiang.AddItem "横向打印"
lblpageCode.BackColor = Me.BackColor
lblInOut.BackColor = Me.BackColor
End Sub
Private Sub Form_Resize()
HuPrintPreview1.Move 10, ToolBar.Height + 10, Me.ScaleWidth - 20, Me.ScaleHeight - ToolBar.Height - 20
End Sub
Public Sub PrnPrint()
On Error GoTo theError
Dim i As Integer, s As String, OldPage As Integer
' HuPrintPreview1.PageStart = 1
' HuPrintPreview1.PageEnd = 1
HuPrintPreview1.PrintToPrinter '打印
Me.MousePointer = 0
Exit Sub
theError:
Me.MousePointer = 0
MsgBox "错误:" + Str(Err.Number) + " " + Err.Description + ",不能打印!", , "打印"
End Sub
Public Sub printerSetup()
On Error GoTo theError
With cdlprnPrv
.Flags = cdlPDHidePrintToFile Or cdlPDPrintSetup
.ShowPrinter
End With
HuPrintPreview1.PrnFresh
Exit Sub
theError:
End Sub
Private Sub HuPrintPreview1_PageChange()
cmd(4).Enabled = HuPrintPreview1.Pages > 1 And HuPrintPreview1.CurrentPage < HuPrintPreview1.Pages
cmd(3).Enabled = HuPrintPreview1.Pages > 1 And HuPrintPreview1.CurrentPage > 1
lblpageCode.Caption = "第" & Format(HuPrintPreview1.CurrentPage, "0") & "页共" & Format(HuPrintPreview1.Pages, "0") & "页"
End Sub