⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pageview.ctl

📁 AddPrintPreviewtoVBV2 增加打印预览的功能
💻 CTL
📖 第 1 页 / 共 5 页
字号:

Public Enum ShowGuidesConstants
    sgHide = 0    'Never show guides.
    sgShow = 1    'Always show guides.
    sgDesignTime = 2    'Show guides at design time (default setting).
End Enum

Public Enum TextAlignmentConstants
    taLeftTop = 0    'Text is aligned to the left and to the top.
    taCenterTop = 1    'Text is aligned to the center and to the top.
    taRightTop = 2    'Text is aligned to the right and to the top.
    taLeftBottom = 3    'Text is aligned to the left and to the bottom.
    taCenterBottom = 4    'Text is aligned to the center and to the bottom.
    taRightBottom = 5    'Text is aligned to the right and to the bottom.
    taLeftMiddle = 6    'Text is aligned to the left and to the middle.
    taCenterMiddle = 7    'Text is aligned to the center and to the middle.
    taRightMiddle = 8    'Text is aligned to the right and to the middle.
    taJustTop = 9    'Text is fully justified and aligned to the top.
    taJustBottom = 10    'Text is fully justified and aligned to the bottom.
    taJustMiddle = 11    'Text is fully justified and aligned to the middle.
End Enum

Public Enum TrueTypeFontsConstants
    ttfBitmap = 1    'Prints TrueType fonts as raster graphics.
    ttfDownload = 2    'Downloads TrueType fonts as soft fonts.
    ttfSubDevice = 3    'Substitute device fonts for TrueType fonts.
    ttfOutline = 4    'Prints TrueType fonts as vector graphics.
End Enum

Public Enum ZoomModeConstants
    zmPercentage = 0    'Use zoom factor set by the user with Zoom property.
    zmThumbnail = 1    'Show as many 1-inch wide preview pages as will fit on the control.
    zmTwoPages = 2    'Show two whole pages, side by side.
    zmWholePage = 3    'Show a whole page.
    zmPageWidth = 4    'Show the page so that it fits horizontally within the control.
    zmStretch = 5    'Stretch the page to fill the control without preserving the aspect ratio.
End Enum

Public Type ABORTWINDOWTYPE
    str_WindowCaption       As String
    str_ButtonCaption       As String
    str_DeviceNameCaption   As String
    str_PageCaption         As String
    enum_WindowPosition     As AbortWindowPositionConstants
End Type

'===============================================
' PRIVATE DECLARATIONS
'===============================================
Private WithEvents ScrollBars As cScrollBars
Attribute ScrollBars.VB_VarHelpID = -1

Private m_enum_CurrentZoomScale     As ZoomScaleConstants
Private Enum ZoomScaleConstants
    zsWholePage = 0
    zs100 = 1
End Enum

'Constants
Private Const m_cint_WkspPgMargin   As Integer = 100
Private Const m_cint_TwipsPerInch   As Integer = 1440
Private Const m_clng_Units          As Long = 1000

'Read-Only
Private m_int_CurrentPage               As Integer
Private m_int_DevicesCount              As Integer
Private m_str_DeviceDriver              As String
Private m_str_DeviceNames               As String
Private m_str_DevicePorts               As String
Private m_int_DevicePortsCount          As Integer
Private m_lng_DeviceResolutionX         As Long
Private m_lng_DeviceResolutionY         As Long
Private m_enum_Error                    As PrinterErrorConstants
Private m_bool_IsPaperSize              As Boolean
Private m_bool_IsPaperBin               As Boolean
Private m_sng_TwipsPerPixelX            As Single
Private m_sng_TwipsPerPixelY            As Single

'Read/Write
Private m_bool_AbortWindow              As Boolean
Private m_typ_AbortWindowSettings       As ABORTWINDOWTYPE
Private m_enum_Collate                  As CollateConstants
Private m_enum_ColorMode                As ColorModeConstants
Private m_int_Copies                    As Integer
Private m_bool_DefaultDevice            As Boolean
Private m_str_DeviceName                As String
Private m_str_DevicePort                As String
Private m_enum_Duplex                   As DuplexConstants
Private m_str_FileName                  As String
Private m_lng_MarginBottom              As Long
Private m_lng_MarginLeft                As Long
Private m_lng_MarginRight               As Long
Private m_lng_MarginTop                 As Long
Private m_enum_MouseZoom                As MouseZoomConstants
Private m_enum_Orientation              As OrientationConstants
Private m_enum_PageBorder               As PageBorderConstants
Private m_lng_PageHeight                As Long
Private m_lng_PageWidth                 As Long
Private m_enum_PaperBin                 As PaperBinConstants
Private m_lng_PaperHeight               As Long
Private m_int_PaperShadowOffset         As Integer
Private m_enum_PaperSize                As PaperSizeConstants
Private m_lng_PaperWidth                As Long
Private m_bool_PhysicalPage             As Boolean
Private m_bool_Preview                  As Boolean
Private m_int_PreviewPage               As Integer
Private m_enum_PrintQuality             As PrintQualityConstants
Private m_int_PrintScale                As Integer
Private m_enum_ShowGuides               As ShowGuidesConstants
Private m_enum_TrueType                 As TrueTypeFontsConstants
Private m_sng_Zoom                      As Single
Private m_int_ZoomMax                   As Integer
Private m_int_ZoomMin                   As Integer
Private m_enum_ZoomMode                 As ZoomModeConstants
Private m_int_ZoomStep                  As Integer

'Misc
Private m_lng_FromPage                  As Long
Private m_lng_ToPage                    As Long
Private m_int_Width                     As Integer
Private m_int_Height                    As Integer

Private m_typ_PrintDlg                  As TPRINTDLG
Private m_typ_PrintDlgFlags             As PRINTDLGFLAGS
Private m_typ_PageSetupDlg              As TPAGESETUPDLG
Private m_typ_PageSetupDlgFlags            As PAGESETUPDLGFLAGS
Private m_typ_DevMode                   As DEVMODE
Private m_typ_DevNames                  As DEVNAMES

Private m_bool_AuthorMode               As Boolean

'*************************************************************
' CLASS CONTRUCTOR/DECONSTRUCTOR
'*************************************************************
Private Sub UserControl_Initialize()
    #If ShowDebugPrints = 1 Then
        Debug.Print "UserControl_Initialize"
    #End If

    #If RunErrHandler = 1 Then
        On Error GoTo Err_Handler
    #Else
        On Error GoTo 0
    #End If

    #If RunStackLogger = 1 Then
        Call LogStackItem("UserControl_Initialize")
    #End If

    'Initiate Scroll Bars
    Set ScrollBars = New cScrollBars
    Call ScrollBars.Create(picWorkspace.hWnd)

    'Initialize Members
    Set Pages = New Pages
    Set Header = New PageHeaderFooter
    Set Footer = New PageHeaderFooter

    'Initiate Printer Structs
    Call vbInitPageSetupDlg(UserControl.hWnd, m_typ_PageSetupDlg, m_typ_PrintDlg, m_typ_DevMode, m_typ_DevNames, puThousandthsOfInches)

    'Initiate First Page
    m_enum_CurrentZoomScale = zsWholePage
    Call pInitPageParams
    Call NewPage

    'Evaluate Printer Device and Display Document
    If Printers.Count <> 0 Then
        m_lng_PaperWidth = Printer.Width
        m_lng_PaperHeight = Printer.Height
        picPage.MouseIcon = LoadResPicture(101, vbResCursor)
        picPage.MousePointer = vbCustom
    Else
        picPage.Visible = False
        picPageShadow.Visible = False
        imgNoPrinters.Visible = True
        lblNoPrinters.Visible = True
    End If

    Exit Sub

Err_Handler:
    Call Err.Raise(Err.Number, App.Title & " - UserControl_Initialize", Err.Description)
End Sub

Private Sub UserControl_Terminate()
    #If RunStackLogger = 1 Then
        Call LogStackItem("UserControl_Terminate")
    #End If

    Set ScrollBars = Nothing
    Set Pages = Nothing
    Set Header = Nothing
    Set Footer = Nothing
End Sub
'*************************************************************

'*************************************************************
' PUBLIC READ ONLY PROPERTIES
'*************************************************************
Property Get CurrentPage() As Integer
Attribute CurrentPage.VB_Description = "Returns the number of the page being printed."
Attribute CurrentPage.VB_MemberFlags = "400"
    #If RunStackLogger = 1 Then
        Call LogStackItem("Get CurrentPage")
    #End If
    CurrentPage = m_int_CurrentPage
End Property

Property Get DevicesCount() As Integer
Attribute DevicesCount.VB_Description = "Returns the number of printing devices available."
Attribute DevicesCount.VB_MemberFlags = "400"
    #If RunStackLogger = 1 Then
        Call LogStackItem("Get DevicesCount")
    #End If
    DevicesCount = Printers.Count    'm_int_DevicesCount
End Property

Property Get DeviceDriver() As String
Attribute DeviceDriver.VB_Description = "Returns the name of the current printer driver."
Attribute DeviceDriver.VB_MemberFlags = "400"
    #If RunStackLogger = 1 Then
        Call LogStackItem("Get DeviceDriver")
    #End If
    DeviceDriver = m_str_DeviceDriver
End Property

Property Get DeviceNames(ByVal x As Integer) As String
Attribute DeviceNames.VB_Description = "Returns the names of the printing devices available."
Attribute DeviceNames.VB_MemberFlags = "400"
    #If RunStackLogger = 1 Then
        Call LogStackItem("Get DeviceNames")
    #End If
    DeviceNames = Printers(x).DeviceName    'm_str_DeviceNames
End Property

Property Get DevicePorts(ByVal x As Integer) As String
Attribute DevicePorts.VB_Description = "Returns the names of the ports to which the current printer is connected."
Attribute DevicePorts.VB_MemberFlags = "400"
    #If RunStackLogger = 1 Then
        Call LogStackItem("Get DevicePorts")
    #End If
    DevicePorts = Printers(x).Port    ' m_str_DevicePorts
End Property

Property Get DevicePortsCount() As Integer
Attribute DevicePortsCount.VB_Description = "Returns the number of ports to which the current printer is connected."
Attribute DevicePortsCount.VB_MemberFlags = "400"
    #If RunStackLogger = 1 Then
        Call LogStackItem("Get DevicePortsCount")
    #End If
    DevicePortsCount = m_int_DevicePortsCount
End Property

Property Get DeviceResolutionX() As Integer
Attribute DeviceResolutionX.VB_Description = "Returns the number of twips per logical inch along the screen width."
Attribute DeviceResolutionX.VB_MemberFlags = "400"
    #If RunStackLogger = 1 Then
        Call LogStackItem("Get DeviceResolutionX")
    #End If
    DeviceResolutionX = m_lng_DeviceResolutionX
End Property

Property Get DeviceResolutionY() As Integer
Attribute DeviceResolutionY.VB_Description = "Returns the number of twips per logical inch along the screen height."
Attribute DeviceResolutionY.VB_MemberFlags = "400"
    #If RunStackLogger = 1 Then
        Call LogStackItem("Get DeviceResolutionY")
    #End If
    DeviceResolutionY = m_lng_DeviceResolutionY
End Property

Property Get Error() As PrinterErrorConstants
Attribute Error.VB_Description = "Returns a code that describes an error condition."
Attribute Error.VB_MemberFlags = "400"
    #If RunStackLogger = 1 Then
        Call LogStackItem("Get Error")
    #End If

    Error = m_enum_Error
End Property

'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MappingInfo=UserControl,UserControl,-1,hDC
Public Property Get hdc() As Long
Attribute hdc.VB_Description = "Returns the control's current hDC."
Attribute hdc.VB_MemberFlags = "400"
    #If RunStackLogger = 1 Then
        Call LogStackItem("Get hdc")
    #End If

    hdc = UserControl.hdc
End Property

Property Get IsPaperSize(ByVal x As PaperSizeConstants) As Boolean
Attribute IsPaperSize.VB_Description = "Returns whether a given page size is available on the current printer."
Attribute IsPaperSize.VB_MemberFlags = "400"
    #If RunStackLogger = 1 Then
        Call LogStackItem("Get IsPaperSize")
    #End If

    On Error Resume Next

    Printer.PaperSize = x
    If Err Then
        Call Err.Clear
        IsPaperSize = False
    Else
        IsPaperSize = True
    End If
    'IsPaperSize = m_bool_IsPaperSize
End Property

Property Get IsPaperBin(ByVal x As PaperBinConstants) As Boolean
Attribute IsPaperBin.VB_Description = "Returns whether a given paper bin is available on the current printer."
Attribute IsPaperBin.VB_MemberFlags = "400"
    #If RunStackLogger = 1 Then
        Call LogStackItem("Get IsPaperBin")
    #End If

    On Error Resume Next

    Printer.PaperBin = x

    If Err Then
        Call Err.Clear
        IsPaperBin = False
    Else
        IsPaperBin = True
    End If
    'IsPaperBin = m_bool_IsPaperBin
End Property

Property Get TwipsPerPixelX() As Single
Attribute TwipsPerPixelX.VB_Description = "Returns the number of twips per printer pixel in the horizontal direction."
    #If RunStackLogger = 1 Then
        Call LogStackItem("Get TwipsPerPixelX")
    #End If

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -