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

📄 frmexport2printer.frm

📁 超经典的打印预览动态库源码 版权: 本资源版权归作者所有 说明: 本资源由源码天空搜集,仅提供学习参考
💻 FRM
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "ComDlg32.OCX"
Begin VB.Form frmExport2Prn 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "输出到打印机"
   ClientHeight    =   2850
   ClientLeft      =   2670
   ClientTop       =   3015
   ClientWidth     =   5625
   Icon            =   "frmExport2Printer.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   2850
   ScaleWidth      =   5625
   ShowInTaskbar   =   0   'False
   Begin VB.CommandButton cmdCancel 
      Cancel          =   -1  'True
      Caption         =   "取消"
      Height          =   285
      Left            =   4455
      TabIndex        =   4
      Top             =   2520
      Width           =   1000
   End
   Begin VB.CommandButton cmdExport 
      Caption         =   "确定"
      Default         =   -1  'True
      Height          =   285
      Left            =   3330
      TabIndex        =   3
      Top             =   2520
      Width           =   1000
   End
   Begin VB.Frame Frame1 
      Height          =   2400
      Left            =   135
      TabIndex        =   5
      Top             =   45
      Width           =   5325
      Begin VB.ComboBox cmbCutPageTo 
         Height          =   315
         Left            =   2835
         Style           =   2  'Dropdown List
         TabIndex        =   15
         Top             =   1170
         Width           =   1095
      End
      Begin VB.ComboBox cmbPageTo 
         Height          =   315
         Left            =   810
         Style           =   2  'Dropdown List
         TabIndex        =   14
         Top             =   1170
         Width           =   1095
      End
      Begin VB.ComboBox cmbCutPageFrom 
         Height          =   315
         Left            =   2835
         Style           =   2  'Dropdown List
         TabIndex        =   13
         Top             =   720
         Width           =   1095
      End
      Begin VB.ComboBox cmbPageFrom 
         Height          =   315
         Left            =   810
         Style           =   2  'Dropdown List
         TabIndex        =   11
         Top             =   720
         Width           =   1095
      End
      Begin MSComDlg.CommonDialog dlg 
         Left            =   5175
         Top             =   1080
         _ExtentX        =   847
         _ExtentY        =   847
         _Version        =   393216
      End
      Begin VB.CommandButton cmdSet 
         Caption         =   "设置..."
         Height          =   285
         Left            =   4230
         TabIndex        =   10
         Top             =   630
         Width           =   870
      End
      Begin VB.CheckBox chkFit 
         Caption         =   "适应打印机纸张"
         Height          =   195
         Left            =   2340
         TabIndex        =   2
         Top             =   1665
         Width           =   1635
      End
      Begin VB.TextBox txtRate 
         Alignment       =   2  'Center
         Height          =   285
         Left            =   810
         TabIndex        =   1
         Text            =   "100"
         Top             =   1620
         Width           =   780
      End
      Begin VB.ComboBox cmbPrinter 
         Height          =   315
         Left            =   810
         Style           =   2  'Dropdown List
         TabIndex        =   0
         Top             =   270
         Width           =   4290
      End
      Begin DllPrint.flatProgressBar prg 
         Height          =   240
         Left            =   810
         TabIndex        =   17
         Top             =   2025
         Width           =   3885
         _extentx        =   6853
         _extenty        =   423
         font            =   "frmExport2Printer.frx":000C
         borderstyle     =   0
         forecolor       =   128
      End
      Begin VB.Label Label8 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "进度"
         Height          =   195
         Left            =   315
         TabIndex        =   18
         Top             =   2040
         Width           =   360
      End
      Begin VB.Image Image1 
         Height          =   480
         Left            =   180
         Picture         =   "frmExport2Printer.frx":0038
         Stretch         =   -1  'True
         Top             =   180
         Width           =   435
      End
      Begin VB.Label Label7 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "分页"
         Height          =   195
         Left            =   2340
         TabIndex        =   16
         Top             =   1215
         Width           =   360
      End
      Begin VB.Label Label4 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "分页"
         Height          =   195
         Left            =   2340
         TabIndex        =   12
         Top             =   780
         Width           =   360
      End
      Begin VB.Label Label6 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H80000005&
         BackStyle       =   0  'Transparent
         Caption         =   "缩放"
         ForeColor       =   &H80000008&
         Height          =   195
         Left            =   315
         TabIndex        =   9
         Top             =   1665
         Width           =   360
      End
      Begin VB.Label Label2 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "页起始"
         Height          =   195
         Left            =   135
         TabIndex        =   8
         Top             =   780
         Width           =   540
      End
      Begin VB.Label Label3 
         AutoSize        =   -1  'True
         Caption         =   "到"
         Height          =   180
         Left            =   495
         TabIndex        =   7
         Top             =   1215
         Width           =   180
      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        =   6
         Top             =   1620
         Width           =   120
      End
   End
End
Attribute VB_Name = "frmExport2Prn"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False


Option Explicit

Public WithEvents rpt           As Report       '*需要传递进来的报表类
Attribute rpt.VB_VarHelpID = -1

Private Sub chkFit_Click()
    If chkFit.Value = 1 Then
        txtRate.Enabled = False
    Else
        txtRate.Enabled = True
    End If
End Sub

Private Sub cmdSet_Click()
'*设置当前的打印机
    
    With dlg
        .CancelError = False
        .Flags = &H40
        .ShowPrinter
    End With

End Sub

Private Sub Form_Load()
    '*窗体居中
    CenterForm Me
    
    '*获取所有打印机
    Dim prn     As Printer

    For Each prn In Printers
        cmbPrinter.AddItem prn.DeviceName
    Next
    
    If cmbPrinter.ListCount > 0 Then
        cmbPrinter.text = cmbPrinter.List(0)
    End If
    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 cmdCancel_Click()
    Unload Me
End Sub

Private Sub cmdExport_Click()
'*输出到文件夹
    On Error GoTo err_other
    '*检查合法性
    If cmbPageFrom.text > cmbPageTo.text Then
        Exit Sub
    End If
    '*输出
    Dim sRate       As Single

    prg.Value = 0
    prg.Visible = True
    
    '*如果适应打印机纸张,则打印机纸张设置不更改,而是改变打印比例
    If chkFit.Value = 0 Then
    
        sRate = CInt(txtRate.text) / 100
        
    End If

    
    If Not rpt.Export2Prn(cmbPageFrom.text, cmbCutPageFrom.text, _
                          cmbPageTo.text, cmbCutPageTo.text, _
                          cmbPrinter.text, sRate, _
                          IIf(chkFit.Value = 1, True, False)) Then
        GoTo err_printer
    End If
        
    
    prg.Visible = False
    
    MsgBox "输出到打印机成功!", vbInformation, Caption
    
    
    Exit Sub
    
    
err_printer:
    MsgBox "输出到打印机错误!", vbExclamation, Caption
    Exit Sub
    
err_other:
    MsgBox "发生不明错误!", vbExclamation, Caption
    Exit Sub
End Sub


Private Sub rpt_PrintProgress(Value As Integer)
    prg.Value = Value
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 + -