📄 printpagelayout.frm
字号:
VERSION 5.00
Begin VB.Form frmPrintPageLayout
Caption = "Print Page Layout"
ClientHeight = 3240
ClientLeft = 60
ClientTop = 345
ClientWidth = 6345
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3240
ScaleWidth = 6345
StartUpPosition = 3 'Windows Default
Begin VB.Frame fraPrinter
Caption = "Printer"
Height = 3135
Left = 3000
TabIndex = 0
Top = 0
Width = 3255
Begin VB.CommandButton cmdPrint
Caption = "Print Page Layout"
Height = 375
Left = 120
TabIndex = 22
Top = 2520
Width = 2655
End
Begin VB.Label lblPrinterOrientation
Height = 495
Left = 1440
TabIndex = 15
Top = 1800
Width = 1695
End
Begin VB.Label Label10
Caption = "Paper Orientation:"
Height = 495
Left = 120
TabIndex = 14
Top = 1800
Width = 1215
End
Begin VB.Label lblPrinterName
Height = 255
Left = 720
TabIndex = 4
Top = 240
Width = 2415
End
Begin VB.Label Label7
Caption = "Name:"
Height = 255
Left = 120
TabIndex = 3
Top = 240
Width = 1095
End
Begin VB.Label lblPrinterSize
Height = 375
Left = 840
TabIndex = 2
Top = 840
Width = 2055
End
Begin VB.Label lblPdcdcrinter
Caption = "Paper Size:"
Height = 615
Left = 120
TabIndex = 1
Top = 840
Width = 855
End
End
Begin VB.Frame Frame2
Caption = "Page"
Height = 3135
Left = 0
TabIndex = 6
Top = 0
Width = 2895
Begin VB.TextBox txbEndPage
Height = 285
Left = 1920
TabIndex = 19
Text = "0"
Top = 2640
Width = 855
End
Begin VB.TextBox txbStartPage
Height = 285
Left = 720
TabIndex = 18
Text = "1"
Top = 2640
Width = 735
End
Begin VB.TextBox txbOverlap
Height = 285
Left = 2040
TabIndex = 17
Text = "0"
Top = 2280
Width = 735
End
Begin VB.OptionButton optLandscape
Caption = "Landscape"
Height = 375
Left = 1320
TabIndex = 12
Top = 1680
Width = 1455
End
Begin VB.OptionButton optPortrait
Caption = "Portrait"
Height = 375
Left = 120
TabIndex = 11
Top = 1680
Width = 1095
End
Begin VB.ComboBox cboPageToPrinterMapping
Height = 315
Left = 120
TabIndex = 10
Text = "Combo2"
Top = 1320
Width = 2655
End
Begin VB.ComboBox cboPageSize
Height = 315
Left = 120
TabIndex = 8
Text = "Combo1"
Top = 600
Width = 2655
End
Begin VB.Label Label1
Caption = "To"
Height = 255
Left = 1560
TabIndex = 21
Top = 2760
Width = 255
End
Begin VB.Label Label5
Caption = "Pages"
Height = 255
Left = 120
TabIndex = 20
Top = 2640
Width = 495
End
Begin VB.Label Label2
Caption = "Overlap between pages"
Height = 495
Left = 120
TabIndex = 16
Top = 2280
Width = 1935
End
Begin VB.Label lblPageCount
Height = 255
Left = 1320
TabIndex = 5
Top = 2040
Width = 855
End
Begin VB.Label Label9
Caption = "Page Count: "
Height = 255
Left = 120
TabIndex = 13
Top = 2040
Width = 1095
End
Begin VB.Label Label8
Caption = "Page to Printer Mapping"
Height = 375
Left = 120
TabIndex = 9
Top = 1080
Width = 2295
End
Begin VB.Label Label6
Caption = "Page Size"
Height = 495
Left = 120
TabIndex = 7
Top = 360
Width = 1095
End
End
End
Attribute VB_Name = "frmPrintPageLayout"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub cboPageSize_Click()
'Set the page size
frmMDIPageLayout.esriCarto.Page.FormID = cboPageSize.ListIndex
'Update printer page display
UpdatePrintPageDisplay
End Sub
Private Sub cboPageToPrinterMapping_Click()
'Set the printer to page mapping
frmMDIPageLayout.esriCarto.Page.PageToPrinterMapping = cboPageToPrinterMapping.ListIndex
'Update printer page display
UpdatePrintPageDisplay
End Sub
Private Sub cmdPrint_Click()
If Not frmMDIPageLayout.PageLayoutControl.Printer Is Nothing Then
'Set mouse pointer
frmMDIPageLayout.PageLayoutControl.MousePointer = esriPointerHourglass
'Get IPrinter interface through the PageLayoutControl's printer
Dim pPrinter As IPrinter
Set pPrinter = frmMDIPageLayout.PageLayoutControl.Printer
'Determine whether printer paper's orientation needs changing
If pPrinter.Paper.Orientation <> frmMDIPageLayout.esriCarto.Page.Orientation Then
pPrinter.Paper.Orientation = frmMDIPageLayout.esriCarto.Page.Orientation
'Update the display
UpdatePrintingDisplay
End If
'Print the page range with the specified overlap
frmMDIPageLayout.PageLayoutControl.PrintPageLayout Val(txbStartPage), Val(txbEndPage), Val(txbOverlap)
'Set the mouse pointer
frmMDIPageLayout.PageLayoutControl.MousePointer = esriPointerDefault
End If
End Sub
Private Sub Form_Load()
'Add esriPageFormID constants to drop down
cboPageSize.AddItem "Letter - 8.5in x 11in. "
cboPageSize.AddItem "Legal - 8.5in x 14in."
cboPageSize.AddItem "Tabloid - 11in x 17in."
cboPageSize.AddItem "C - 17in x 22in."
cboPageSize.AddItem "D - 22in x 34in."
cboPageSize.AddItem "E - 34in x 44in."
cboPageSize.AddItem "A5 - 148mm x 210mm."
cboPageSize.AddItem "A4 - 210mm x 297mm."
cboPageSize.AddItem "A3 - 297mm x 420mm."
cboPageSize.AddItem "A2 - 420mm x 594mm."
cboPageSize.AddItem "A1 - 594mm x 841mm."
cboPageSize.AddItem "A0 - 841mm x 1189mm."
cboPageSize.AddItem "Custom Page Size."
cboPageSize.AddItem "Same as Printer Form."
cboPageSize.ListIndex = 7
'Add esriPageToPrinterMapping constants to drop down
cboPageToPrinterMapping.AddItem "0: Crop"
cboPageToPrinterMapping.AddItem "1: Scale"
cboPageToPrinterMapping.AddItem "2: Tile"
cboPageToPrinterMapping.ListIndex = 1
optPortrait.Value = 1
'Display printer details
UpdatePrintingDisplay
Call menuViewLayoutView
End Sub
Private Sub UpdatePrintPageDisplay()
'Determine the number of pages
Dim iPageCount As Integer
iPageCount = frmMDIPageLayout.PageLayoutControl.PrinterPageCount(Val(txbOverlap.Text))
lblPageCount.Caption = iPageCount
'Validate start and end pages
Dim iPageStart As Integer
Dim iPageEnd As Integer
iPageStart = Val(txbStartPage.Text)
iPageEnd = Val(txbEndPage.Text)
If iPageStart < 1 Or iPageStart > iPageCount Then
txbStartPage.Text = 1
End If
If iPageEnd < 1 Or iPageEnd > iPageCount Then
txbEndPage.Text = iPageCount
End If
End Sub
Private Sub UpdatePrintingDisplay()
If Not frmMDIPageLayout.PageLayoutControl.Printer Is Nothing Then
'Get IPrinter interface through the PageLayoutControl's printer
Dim pPrinter As IPrinter
Set pPrinter = frmMDIPageLayout.PageLayoutControl.Printer
'Determine the orientation of the printer's paper
If pPrinter.Paper.Orientation = 1 Then
lblPrinterOrientation.Caption = "Portrait"
Else
lblPrinterOrientation.Caption = "Landscape"
End If
'Determine the printer name
lblPrinterName.Caption = pPrinter.Paper.PrinterName
'Determine the printer's paper size
Dim dWidth As Double
Dim dheight As Double
pPrinter.Paper.QueryPaperSize dWidth, dheight
lblPrinterSize.Caption = Format$(dWidth, "###.000") & " by " & Format$(dheight, "###.000") & " Inches"
End If
End Sub
Private Sub txbOverlap_LostFocus()
'Update printer page display
UpdatePrintPageDisplay
End Sub
Private Sub optLandscape_Click()
'Set the page orientation
If frmMDIPageLayout.esriCarto.Page.FormID <> esriPageFormSameAsPrinter Then
frmMDIPageLayout.esriCarto.Page.Orientation = 2
End If
'Update printer page display
UpdatePrintPageDisplay
End Sub
Private Sub optPortrait_Click()
'Set the page orientation
If frmMDIPageLayout.esriCarto.Page.FormID <> esriPageFormSameAsPrinter Then
frmMDIPageLayout.esriCarto.Page.Orientation = 1
End If
'Update printer page display
UpdatePrintPageDisplay
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -