📄 frmprint.frm
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "Comdlg32.ocx"
Begin VB.Form FrmPrint
BorderStyle = 1 'Fixed Single
Caption = "打印地图"
ClientHeight = 3090
ClientLeft = 45
ClientTop = 330
ClientWidth = 2775
Icon = "FrmPrint.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3090
ScaleWidth = 2775
ShowInTaskbar = 0 'False
StartUpPosition = 1 '所有者中心
Begin VB.Frame Frame1
Caption = "打印尺寸设置"
Height = 2055
Left = 120
TabIndex = 3
Top = 120
Width = 2535
Begin VB.CheckBox Check2
Caption = "按实际宽高比"
Enabled = 0 'False
Height = 255
Left = 240
TabIndex = 12
Top = 1680
Value = 1 'Checked
Width = 1575
End
Begin VB.TextBox Text2
Enabled = 0 'False
Height = 270
Left = 960
TabIndex = 9
Top = 1320
Width = 975
End
Begin VB.TextBox Text1
Enabled = 0 'False
Height = 270
Left = 960
TabIndex = 6
Top = 960
Width = 975
End
Begin VB.OptionButton Option2
Caption = "自定义设置"
Height = 255
Left = 240
TabIndex = 5
Top = 600
Width = 1935
End
Begin VB.OptionButton Option1
Caption = "当前实际尺寸大小"
Height = 255
Left = 240
TabIndex = 4
Top = 240
Value = -1 'True
Width = 1815
End
Begin VB.Label Label4
Caption = "毫米"
Enabled = 0 'False
Height = 255
Left = 2040
TabIndex = 11
Top = 1320
Width = 375
End
Begin VB.Label Label3
Caption = "高度:"
Enabled = 0 'False
Height = 255
Left = 240
TabIndex = 10
Top = 1320
Width = 615
End
Begin VB.Label Label2
Caption = "毫米"
Enabled = 0 'False
Height = 255
Left = 2040
TabIndex = 8
Top = 960
Width = 375
End
Begin VB.Label Label1
Caption = "宽度:"
Enabled = 0 'False
Height = 255
Left = 240
TabIndex = 7
Top = 960
Width = 615
End
End
Begin VB.CheckBox Check1
Caption = "突出显示所选择地物"
Height = 255
Left = 360
TabIndex = 2
Top = 2280
Width = 1935
End
Begin VB.CommandButton Command2
Caption = "打印设置"
Height = 375
Left = 360
TabIndex = 1
Top = 2640
Width = 1095
End
Begin MSComDlg.CommonDialog CommonDialog1
Left = 2280
Top = 0
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.CommandButton Command1
Caption = "打印"
Height = 375
Left = 1680
TabIndex = 0
Top = 2640
Width = 735
End
End
Attribute VB_Name = "FrmPrint"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim MyScale As Double
Private Sub Check1_Click()
If Check1.Value = 0 Then FrmMain.MyMap.ExportSelection = False
If Check1.Value = 1 Then FrmMain.MyMap.ExportSelection = True
End Sub
Private Sub Command1_Click()
Dim MapErr
On Error GoTo MapErr
With CommonDialog1
.DialogTitle = "打印"
.CancelError = True
.ShowPrinter
End With
Printer.CurrentX = 0
Printer.CurrentY = 0
Printer.Print " "
If Option1.Value = True Then FrmMain.MyMap.PrintMap Printer.hDC, 0, 0, FrmMain.MyMap.MapPaperWidth * 100, FrmMain.MyMap.MapPaperHeight * 100
If Option2.Value = True Then FrmMain.MyMap.PrintMap Printer.hDC, 0, 0, Val(Text1.Text) * 100, Val(Text2.Text) * 100
Printer.NewPage
Printer.EndDoc
Unload Me
Exit Sub
MapErr:
If Err <> 32755 Then
MsgBox "打印地图出错,错误代码为#" & Str(Err) & ": " & Error
Unload Me
End If
End Sub
Private Sub Command2_Click()
On Error Resume Next
With CommonDialog1
.DialogTitle = "打印设置"
.CancelError = True
.Flags = cdlPDPrintSetup
.ShowPrinter
End With
If Err <> 32755 Then Exit Sub
End Sub
Private Sub Form_Load()
If FrmMain.MyMap.ExportSelection Then Check1.Value = 1
FrmMain.MyMap.PaperUnit = miPaperUnitMillimeter
MyScale = FrmMain.MyMap.MapPaperWidth / FrmMain.MyMap.MapPaperHeight
Text1.Text = Trim(Str(CInt(FrmMain.MyMap.MapPaperWidth))) '文本框显示地图窗口宽高
Text2.Text = Trim(Str(CInt(FrmMain.MyMap.MapPaperHeight)))
End Sub
Private Sub Option1_Click()
If Option2.Value = True Then
Label1.Enabled = True
Label2.Enabled = True
Label3.Enabled = True
Label4.Enabled = True
Text1.Enabled = True
Text2.Enabled = True
Check2.Enabled = True
Else
Label1.Enabled = False
Label2.Enabled = False
Label3.Enabled = False
Label4.Enabled = False
Text1.Enabled = False
Text2.Enabled = False
Check2.Enabled = False
End If
End Sub
Private Sub Option2_Click()
If Option2.Value = True Then
Label1.Enabled = True
Label2.Enabled = True
Label3.Enabled = True
Label4.Enabled = True
Text1.Enabled = True
Text2.Enabled = True
Check2.Enabled = True
Else
Label1.Enabled = False
Label2.Enabled = False
Label3.Enabled = False
Label4.Enabled = False
Text1.Enabled = False
Text2.Enabled = False
Check2.Enabled = False
End If
End Sub
Private Sub Text1_LostFocus()
If Val(Text1.Text) <= 0 Then
MsgBox "输入有错误,请输入大于0的整数"
Text1.SetFocus
Exit Sub
End If
If Check2.Value = 1 Then
Text2.Text = Trim(Str(CInt(Val(Text1.Text) / MyScale)))
End If
End Sub
Private Sub Text2_LostFocus()
If Val(Text2.Text) <= 0 Then
MsgBox "输入有错误,请输入大于0的整数"
Text1.SetFocus
Exit Sub
End If
If Check2.Value = 1 Then
Text1.Text = Trim(Str(CInt(Val(Text2.Text) * MyScale)))
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -