📄 frmexport2jpg.frm
字号:
VERSION 5.00
Begin VB.Form frmExport2Jpg
BorderStyle = 3 'Fixed Dialog
Caption = "输出到图形"
ClientHeight = 2850
ClientLeft = 2250
ClientTop = 2925
ClientWidth = 5610
Icon = "frmExport2Jpg.frx":0000
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2850
ScaleWidth = 5610
ShowInTaskbar = 0 'False
Begin VB.Frame Frame1
Height = 2400
Left = 135
TabIndex = 10
Top = 45
Width = 5325
Begin VB.TextBox txtPrefix
Height = 285
Left = 4455
TabIndex = 21
Top = 1575
Width = 600
End
Begin VB.CheckBox chkType
Caption = "生成BMP图(默认JPG)"
Height = 195
Left = 2160
TabIndex = 19
Top = 1665
Width = 2040
End
Begin VB.TextBox txtPath
Height = 285
Left = 810
TabIndex = 0
Top = 270
Width = 4290
End
Begin VB.TextBox txtRate
Alignment = 2 'Center
Height = 285
Left = 810
TabIndex = 6
Text = "100"
Top = 1620
Width = 780
End
Begin VB.CommandButton cmdView
Caption = "浏览..."
Height = 285
Left = 4230
TabIndex = 1
Top = 585
Width = 870
End
Begin VB.ComboBox cmbPageFrom
Height = 315
Left = 810
Style = 2 'Dropdown List
TabIndex = 2
Top = 720
Width = 1095
End
Begin VB.ComboBox cmbCutPageFrom
Height = 315
Left = 2835
Style = 2 'Dropdown List
TabIndex = 3
Top = 720
Width = 1095
End
Begin VB.ComboBox cmbPageTo
Height = 315
Left = 810
Style = 2 'Dropdown List
TabIndex = 4
Top = 1170
Width = 1095
End
Begin VB.ComboBox cmbCutPageTo
Height = 315
Left = 2835
Style = 2 'Dropdown List
TabIndex = 5
Top = 1170
Width = 1095
End
Begin DllPrint.flatProgressBar prg
Height = 240
Left = 810
TabIndex = 11
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 Label1
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "文件名前缀"
Height = 195
Left = 4095
TabIndex = 20
Top = 1215
Width = 900
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 = 18
Top = 1620
Width = 120
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "到"
Height = 180
Left = 495
TabIndex = 17
Top = 1215
Width = 180
End
Begin VB.Label Label2
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "页起始"
Height = 195
Left = 135
TabIndex = 16
Top = 780
Width = 540
End
Begin VB.Label Label6
Appearance = 0 'Flat
AutoSize = -1 'True
BackColor = &H80000005&
BackStyle = 0 'Transparent
Caption = "缩放"
ForeColor = &H80000008&
Height = 195
Left = 315
TabIndex = 15
Top = 1665
Width = 360
End
Begin VB.Label Label4
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "分页"
Height = 195
Left = 2340
TabIndex = 14
Top = 780
Width = 360
End
Begin VB.Label Label7
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "分页"
Height = 195
Left = 2340
TabIndex = 13
Top = 1215
Width = 360
End
Begin VB.Image Image1
Height = 480
Left = 180
Picture = "frmExport2Jpg.frx":000C
Stretch = -1 'True
Top = 180
Width = 480
End
Begin VB.Label Label8
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "进度"
Height = 195
Left = 315
TabIndex = 12
Top = 2040
Width = 360
End
End
Begin VB.CommandButton cmdExport
Caption = "确定"
Default = -1 'True
Height = 285
Left = 3330
TabIndex = 7
Top = 2520
Width = 1000
End
Begin VB.CommandButton cmdCancel
Cancel = -1 'True
Caption = "取消"
Height = 285
Left = 4455
TabIndex = 8
Top = 2520
Width = 1000
End
Begin VB.PictureBox pic
Appearance = 0 'Flat
AutoRedraw = -1 'True
BackColor = &H80000005&
BorderStyle = 0 'None
ForeColor = &H80000008&
Height = 240
Left = 270
ScaleHeight = 240
ScaleWidth = 420
TabIndex = 9
TabStop = 0 'False
Top = 2520
Visible = 0 'False
Width = 420
End
End
Attribute VB_Name = "frmExport2Jpg"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Public rpt As Report '*需要传递进来的报表类
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdExport_Click()
'*输出到文件夹
Dim pageFrom As Integer
Dim pageTo As Integer
pageFrom = cmbPageFrom.text
pageTo = cmbPageTo.text
On Error GoTo err_other
'*检查合法性
If Dir(txtPath.text, vbDirectory) = "" Then
GoTo err_path
End If
If pageFrom > pageTo Then
Exit Sub
End If
'*输出
Dim page As Integer
Dim cutpage As Integer
prg.Value = 0
prg.Visible = True
With rpt
For page = pageFrom To pageTo
For cutpage = 1 To .cutpages
If Not ((page = pageFrom And cutpage < cmbCutPageFrom.text) _
Or (page = pageTo And cutpage > cmbCutPageTo.text)) Then
If Not (rpt.Export2Jpg(txtPath.text, pic, _
page, cutpage, _
page, cutpage, _
CInt(txtRate.text) / 100, _
IIf(chkType.Value = 1, True, False), _
txtPrefix.text)) Then
GoTo err_export
End If
End If
prg.Value = (page - pageFrom + 1) / (pageTo - pageFrom + 1) * 100
prg.Refresh
Next cutpage
Next page
End With
prg.Visible = False
MsgBox "输出图形文件成功!", vbInformation, Caption
Exit Sub
err_path:
MsgBox "文件夹不合法!", vbExclamation, Caption
SelAllTxt txtPath
Exit Sub
err_export:
MsgBox "输出到图形文件错误!", vbExclamation, Caption
Exit Sub
err_other:
MsgBox "发生不明错误!", vbExclamation, Caption
Exit Sub
End Sub
Private Sub cmdView_Click()
'*浏览文件夹
Dim str As String
str = BrowseForFolder(Me.hWnd, "请选择要输出图形的文件夹")
If str <> "" Then
txtPath.text = str
End If
SelAllTxt txtPath
End Sub
Private Sub Form_Load()
'*窗体居中
CenterForm Me
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 txtPrefix_GotFocus()
SelAllTxt txtPrefix
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 + -