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

📄 frmprint.frm

📁 This application provides much functionality for creating data-driven reports, including preview, gr
💻 FRM
📖 第 1 页 / 共 2 页
字号:
      Begin VB.Label Label1 
         Caption         =   "Range"
         Height          =   195
         Index           =   2
         Left            =   180
         TabIndex        =   16
         Top             =   1080
         Width           =   645
      End
      Begin VB.Label Label1 
         Caption         =   "To:"
         Enabled         =   0   'False
         Height          =   195
         Index           =   0
         Left            =   2040
         TabIndex        =   12
         Top             =   600
         Width           =   255
      End
   End
   Begin MSComctlLib.ImageList imlPrinters 
      Left            =   0
      Top             =   0
      _ExtentX        =   1005
      _ExtentY        =   1005
      BackColor       =   -2147483643
      ImageWidth      =   16
      ImageHeight     =   16
      MaskColor       =   12632256
      _Version        =   393216
      BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
         NumListImages   =   2
         BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmPrint.frx":000C
            Key             =   "pl"
         EndProperty
         BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmPrint.frx":03A6
            Key             =   "pn"
         EndProperty
      EndProperty
   End
   Begin VB.CommandButton cmdCancel 
      Cancel          =   -1  'True
      Caption         =   "Cancel"
      Height          =   360
      Left            =   4600
      Style           =   1  'Graphical
      TabIndex        =   8
      Top             =   1980
      Width           =   1400
   End
   Begin VB.CommandButton cmdPrint 
      Caption         =   "Print"
      Default         =   -1  'True
      Height          =   360
      Left            =   3165
      Style           =   1  'Graphical
      TabIndex        =   7
      Top             =   1980
      Width           =   1400
   End
   Begin VB.Image imgCollated 
      Appearance      =   0  'Flat
      Height          =   570
      Index           =   0
      Left            =   1440
      Picture         =   "frmPrint.frx":0740
      Top             =   1860
      Visible         =   0   'False
      Width           =   1410
   End
   Begin VB.Image imgCollated 
      Appearance      =   0  'Flat
      Height          =   570
      Index           =   1
      Left            =   0
      Picture         =   "frmPrint.frx":0BE2
      Top             =   1890
      Visible         =   0   'False
      Width           =   1410
   End
End
Attribute VB_Name = "frmPrint"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private pIsPrint As Boolean


Public Property Get isPrint() As Boolean
    isPrint = pIsPrint
End Property

Private Sub chkCollate_Click()
    imgCollate.Picture = imgCollated(chkCollate.Value).Picture
End Sub

Private Sub cmdCancel_Click()
    cmdPrint.Enabled = False
    cmdCancel.Enabled = False
    pIsPrint = False
    Hide_
    Me.Hide
End Sub

Private Sub cmdPrint_Click()
Dim p As Printer, dn As String, f As Integer, t As Integer, c As Integer

    f = Val(txtFrom.Text)
    t = Val(txtTo.Text)
    If optPages.Value And (t < f Or f = 0 Or t = 0) Then
        CInteraction.ShowMsgBox , "Invalid print range.", , , , , imgExclamationEx, , 1
        txtFrom.SetFocus
        Exit Sub
    End If

    c = Val(txtCopies.Text)
    If c < 1 Or c > 999 Then
        CInteraction.ShowMsgBox , "Copies can be between 1 and 999", , , , , imgExclamationEx, , 1
        txtCopies.SetFocus
        Exit Sub
    End If

    MousePointer = vbHourglass

    cmdPrint.Enabled = False
    cmdCancel.Enabled = False
    dn = cboPrinters.Text
    For Each p In Printers
        If dn = p.DeviceName Then
            Set Printer = p
'            Printer.ScaleMode = vbMillimeters
            Exit For
        End If
    Next p

    With PrinterEx
        .Collate = CBool(chkCollate.Value)
        .Copies = c
        .Range = cboRange.SelectedItem.Index - 1
        If optPages.Value Then
            .FromPage = f
            .ToPage = t
        Else
            .FromPage = 0
            .ToPage = 0
        End If
    End With

    'With Printer
    '    MsgBox "print area: " & .ScaleWidth & "x" & .ScaleHeight & vbCrLf & _
    '                    "paper size: " & .ScaleX(.Width, vbTwips, vbMillimeters) & "x" & .ScaleY(.Height, vbTwips, vbMillimeters)
    'End With
    pIsPrint = True
    Hide_
    Me.Hide
    MousePointer = vbDefault
End Sub

Private Sub Hide_()
Dim CEff As New clsWndEffects

    CEff.HideOrShowRect Me.hWnd, 5, 5, ceffHide, 10
    CEff.DeleteObj
End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyF4 And Shift = vbAltMask Then
        KeyCode = 0
    End If
End Sub

Private Sub Form_Load()
Dim p As Printer, defdn As String, dn As String, defidx As Integer
Dim strIco As String

    pIsPrint = False

    With cboRange.ComboItems
        .Clear
        .Add , , "all pages"
        .Add , , "odd pages"
        .Add , , "even pages"
    End With

    defidx = 1
    If Printers.Count > 0 Then
        defdn = Printer.DeviceName
        For Each p In Printers
            dn = p.DeviceName

            strIco = "pl"
            If Len(p.Port) > 1 Then
                If Left(p.Port, 2) = "\\" Then
                    strIco = "pn"
                End If
            End If
            If Len(dn) > 1 Then
                If Left(dn, 2) = "\\" Then
                    strIco = "pn"
                End If
            End If

            cboPrinters.ComboItems.Add , , dn, strIco
            If dn = defdn Then defidx = cboPrinters.ComboItems.Count
        Next p
    Else
        cboPrinters.ComboItems.Add , , "Can't find any printer.", "pl"
        cmdPrint.Enabled = False
    End If
    cboPrinters.ComboItems(defidx).Selected = True
    chkCollate_Click

    Call DisableClose(Me.hWnd)
    Hook_PrnLst cboPrinters.hWnd
    Hook_PPortion cboRange.hWnd
End Sub

Private Sub Form_Unload(Cancel As Integer)
    UnHook_PrnLst
    UnHook_PPortion
    pIsPrint = False
End Sub

Private Sub lblAll_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    optAll.Value = 1 - optAll.Value
End Sub

Private Sub lblCollate_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    chkCollate.Value = 1 - chkCollate.Value
End Sub

Private Sub lblPages_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    optPages.Value = 1 - optPages.Value
End Sub

Private Sub optAll_Click()
    Pages
End Sub

Private Sub optPages_Click()
    Pages
End Sub

Private Sub Pages()
Dim b As Boolean

    b = optPages.Value
    txtFrom.Enabled = b
    txtTo.Enabled = b
    udFrom.Enabled = b
    udTo.Enabled = b
    Label1(0).Enabled = b
End Sub

Private Sub txtCopies_GotFocus()
    SelectText txtCopies
End Sub

Private Sub txtFrom_GotFocus()
    SelectText txtFrom
End Sub

Private Sub txtTo_GotFocus()
    SelectText txtTo
End Sub

⌨️ 快捷键说明

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