?? frmexport2printer.frm
字號:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "comdlg32.ocx"
Begin VB.Form frmExport2Prn
BorderStyle = 3 'Fixed Dialog
Caption = "輸出到打印機"
ClientHeight = 2850
ClientLeft = 2670
ClientTop = 3015
ClientWidth = 5625
Icon = "frmExport2Printer.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2850
ScaleWidth = 5625
ShowInTaskbar = 0 'False
Begin VB.CommandButton cmdCancel
Cancel = -1 'True
Caption = "取消"
Height = 285
Left = 4455
TabIndex = 4
Top = 2520
Width = 1000
End
Begin VB.CommandButton cmdExport
Caption = "確定"
Default = -1 'True
Height = 285
Left = 3330
TabIndex = 3
Top = 2520
Width = 1000
End
Begin VB.Frame Frame1
Height = 2400
Left = 135
TabIndex = 5
Top = 45
Width = 5325
Begin VB.ComboBox cmbCutPageTo
Height = 315
Left = 2835
Style = 2 'Dropdown List
TabIndex = 15
Top = 1170
Width = 1095
End
Begin VB.ComboBox cmbPageTo
Height = 315
Left = 810
Style = 2 'Dropdown List
TabIndex = 14
Top = 1170
Width = 1095
End
Begin VB.ComboBox cmbCutPageFrom
Height = 315
Left = 2835
Style = 2 'Dropdown List
TabIndex = 13
Top = 720
Width = 1095
End
Begin VB.ComboBox cmbPageFrom
Height = 315
Left = 810
Style = 2 'Dropdown List
TabIndex = 11
Top = 720
Width = 1095
End
Begin MSComDlg.CommonDialog dlg
Left = 5175
Top = 1080
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.CommandButton cmdSet
Caption = "設置..."
Height = 285
Left = 4230
TabIndex = 10
Top = 630
Width = 870
End
Begin VB.CheckBox chkFit
Caption = "適應打印機紙張"
Height = 195
Left = 2340
TabIndex = 2
Top = 1665
Width = 1635
End
Begin VB.TextBox txtRate
Alignment = 2 'Center
Height = 285
Left = 810
TabIndex = 1
Text = "100"
Top = 1620
Width = 780
End
Begin VB.ComboBox cmbPrinter
Height = 315
Left = 810
Style = 2 'Dropdown List
TabIndex = 0
Top = 270
Width = 4290
End
Begin DllPrint.flatProgressBar prg
Height = 240
Left = 810
TabIndex = 17
Top = 2025
Width = 3885
_ExtentX = 6853
_ExtentY = 423
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BorderStyle = 0
ForeColor = 128
End
Begin VB.Label Label8
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "進度"
Height = 195
Left = 315
TabIndex = 18
Top = 2040
Width = 360
End
Begin VB.Image Image1
Height = 480
Left = 180
Picture = "frmExport2Printer.frx":000C
Stretch = -1 'True
Top = 180
Width = 435
End
Begin VB.Label Label7
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "分頁"
Height = 195
Left = 2340
TabIndex = 16
Top = 1215
Width = 360
End
Begin VB.Label Label4
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "分頁"
Height = 195
Left = 2340
TabIndex = 12
Top = 780
Width = 360
End
Begin VB.Label Label6
Appearance = 0 'Flat
AutoSize = -1 'True
BackColor = &H80000005&
BackStyle = 0 'Transparent
Caption = "縮放"
ForeColor = &H80000008&
Height = 195
Left = 315
TabIndex = 9
Top = 1665
Width = 360
End
Begin VB.Label Label2
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "頁起始"
Height = 195
Left = 135
TabIndex = 8
Top = 780
Width = 540
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "到"
Height = 180
Left = 495
TabIndex = 7
Top = 1215
Width = 180
End
Begin VB.Label Label5
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "%"
BeginProperty Font
Name = "宋體"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 240
Left = 1800
TabIndex = 6
Top = 1620
Width = 120
End
End
End
Attribute VB_Name = "frmExport2Prn"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Public WithEvents rpt As Report '*需要傳遞進來的報表類
Attribute rpt.VB_VarHelpID = -1
Private Sub chkFit_Click()
If chkFit.Value = 1 Then
txtRate.Enabled = False
Else
txtRate.Enabled = True
End If
End Sub
Private Sub cmdSet_Click()
'*設置當前的打印機
With dlg
.CancelError = False
.Flags = &H40
.ShowPrinter
End With
End Sub
Private Sub Form_Load()
'*窗體居中
CenterForm Me
'*獲取所有打印機
Dim prn As Printer
For Each prn In Printers
cmbPrinter.AddItem prn.DeviceName
Next
If cmbPrinter.ListCount > 0 Then
cmbPrinter.text = cmbPrinter.List(0)
End If
Dim i As Integer
With rpt
For i = 1 To .pages
cmbPageFrom.AddItem i
cmbPageTo.AddItem i
Next i
For i = 1 To .cutpages
cmbCutPageFrom.AddItem i
cmbCutPageTo.AddItem i
Next i
cmbPageFrom.text = 1
cmbPageTo.text = .pages
cmbCutPageFrom.text = 1
cmbCutPageTo.text = .cutpages
End With
'*初始化文本框
InitText txtRate, 0
End Sub
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdExport_Click()
'*輸出到文件夾
On Error GoTo err_other
'*檢查合法性
If cmbPageFrom.text > cmbPageTo.text Then
Exit Sub
End If
'*輸出
Dim sRate As Single
prg.Value = 0
prg.Visible = True
'*如果適應打印機紙張,則打印機紙張設置不更改,而是改變打印比例
If chkFit.Value = 0 Then
sRate = CInt(txtRate.text) / 100
End If
If Not rpt.Export2Prn(cmbPageFrom.text, cmbCutPageFrom.text, _
cmbPageTo.text, cmbCutPageTo.text, _
cmbPrinter.text, sRate, _
IIf(chkFit.Value = 1, True, False)) Then
GoTo err_printer
End If
prg.Visible = False
MsgBox "輸出到打印機成功!", vbInformation, Caption
Exit Sub
err_printer:
MsgBox "輸出到打印機錯誤!", vbExclamation, Caption
Exit Sub
err_other:
MsgBox "發生不明錯誤!", vbExclamation, Caption
Exit Sub
End Sub
Private Sub rpt_PrintProgress(Value As Integer)
prg.Value = Value
End Sub
Private Sub txtRate_GotFocus()
SelAllTxt txtRate
End Sub
Private Sub txtRate_Validate(Cancel As Boolean)
fmtTxtData txtRate, 0, 500, 10
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -