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

📄 form1.frm

📁 打印预览程序
💻 FRM
📖 第 1 页 / 共 3 页
字号:
VERSION 5.00
Begin VB.Form Form1 
   BorderStyle     =   3  'Fixed Dialog
   ClientHeight    =   5715
   ClientLeft      =   2745
   ClientTop       =   1785
   ClientWidth     =   4875
   Icon            =   "Form1.frx":0000
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   5715
   ScaleWidth      =   4875
   Begin VB.TextBox Text1 
      Height          =   1035
      Left            =   255
      MultiLine       =   -1  'True
      ScrollBars      =   3  'Both
      TabIndex        =   10
      Text            =   "Form1.frx":000C
      Top             =   4455
      Width           =   4560
   End
   Begin VB.PictureBox Picture1 
      Align           =   1  'Align Top
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      BorderStyle     =   0  'None
      ForeColor       =   &H80000008&
      Height          =   1305
      Left            =   0
      ScaleHeight     =   1305
      ScaleWidth      =   4875
      TabIndex        =   6
      TabStop         =   0   'False
      Top             =   0
      Width           =   4875
      Begin VB.Label Label2 
         Appearance      =   0  'Flat
         BackColor       =   &H80000005&
         BackStyle       =   0  'Transparent
         Caption         =   $"Form1.frx":0A43
         ForeColor       =   &H80000008&
         Height          =   1215
         Left            =   135
         TabIndex        =   7
         Top             =   45
         Width           =   4620
      End
   End
   Begin VB.PictureBox picPrinting 
      BackColor       =   &H80000005&
      Height          =   3180
      Left            =   5295
      ScaleHeight     =   3120
      ScaleWidth      =   3615
      TabIndex        =   2
      TabStop         =   0   'False
      Top             =   4410
      Visible         =   0   'False
      Width           =   3675
      Begin VB.Label Label1 
         Alignment       =   2  'Center
         BackStyle       =   0  'Transparent
         Caption         =   "Printing... Please wait"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   24
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   1335
         Left            =   120
         TabIndex        =   3
         Top             =   300
         Width           =   3405
      End
   End
   Begin VB.CommandButton Command4 
      Caption         =   "Room Tags"
      Height          =   495
      Left            =   1215
      TabIndex        =   5
      Top             =   2910
      Width           =   2595
   End
   Begin VB.CommandButton Command2 
      Caption         =   "Example Of EndOfPage Check"
      Height          =   495
      Left            =   1215
      TabIndex        =   1
      Top             =   1920
      Width           =   2595
   End
   Begin VB.CommandButton Command1 
      Caption         =   "Print Preview Instructions"
      Height          =   495
      Left            =   1215
      TabIndex        =   0
      Top             =   1425
      Width           =   2595
   End
   Begin VB.CommandButton Command3 
      Caption         =   "Ignore CF and LF"
      Height          =   495
      Left            =   1215
      TabIndex        =   4
      Top             =   2415
      Width           =   2595
   End
   Begin VB.CommandButton Command5 
      Caption         =   "House Order Form"
      Height          =   375
      Left            =   1215
      TabIndex        =   8
      Top             =   3405
      Width           =   2595
   End
   Begin VB.CommandButton Command6 
      Caption         =   "Print the Multi-Line Textbox Below"
      Height          =   570
      Left            =   1215
      TabIndex        =   9
      Top             =   3780
      Width           =   2595
   End
   Begin VB.Line Line1 
      BorderWidth     =   4
      X1              =   0
      X2              =   4845
      Y1              =   1305
      Y2              =   1305
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private Sub Command1_Click()
  Const C0 = 1
  Const C1 = 1.1
  Const C2 = 2.2
  Const C3 = 7
  Dim memCurrentYt As Single, memCurrentYb As Single
  
    Set cPrint = New clsMultiPgPreview
    
    frmPrinterSetUp.Show vbModal
    If QuitCommand Then
        Set cPrint = Nothing
        Exit Sub
    End If
    
SendToPrinter:
    Screen.MousePointer = vbHourglass
    picPrinting.Visible = True
    DoEvents
    
    cPrint.pStartDoc
    
    '/* Print Cover page ********************************************************************
    cPrint.pPrintPicture LoadPicture(App.Path & "\cover.jpg"), , , , , , False
    cPrint.pFontName
    cPrint.pBox 0.5, 0.5, cPrint.GetPaperWidth - 1, cPrint.GetPaperHeight - 1
    cPrint.FontSize = 24
    cPrint.FontBold = True
    cPrint.CurrentY = 3
    cPrint.pBox 1, , cPrint.GetPaperWidth - 2, , &HC0E0FF, , vbFSSolid
    cPrint.FontTransparent = True
    cPrint.pCenter " Print Preview and More "
    cPrint.FontSize = 14
    cPrint.pPrint
    cPrint.pCenter "By: Morgan Haueisen"
    cPrint.pPrint
    cPrint.FontBold = False
    cPrint.FontSize = 12

    '/* Two different ways to center a long text string
    cPrint.pMultiline "This is page 1 of 6.  Use the horizontal / vertical scroll bars and buttons " & _
                      "on the side bar to move the pages.  You can also click and drag the page " & _
                      "with your mouse, use the arrow keys to move the page around and " & _
                      "change between pages.  You can also use keys PageUp, PageDown, Home, End, or G (goto).", 2, cPrint.GetPaperWidth - 2

    'cPrint.pCenterMultiline "This is page 1 of 6.  Use the horizontal / vertical scroll bars and buttons " & _
                      "on the side bar to move the pages.  You can also click and drag the page " & _
                      "with your mouse, use the arrow keys to move the page around and " & _
                      "change between pages.  You can also use keys PageUp, PageDown, Home, End, or G (goto).", 2, cPrint.GetPaperWidth - 2

    cPrint.pPrint
    cPrint.ForeColor = vbRed
    cPrint.pCenter "Please look at Readme.htm for additional information."
    cPrint.ForeColor = vbBlack

    cPrint.CurrentY = cPrint.GetPaperHeight - 1.5
    cPrint.pPrintedDate True
    cPrint.pNewPage


    '/* Page 2 *********************************************************************************
    cPrint.pHeader "A Print Preview Demo Project", "By: Morgan Haueisen"

    cPrint.FontSize = 11
    cPrint.pPrint "This Print Preview code may not be the best solution but it gets" & _
                      " the job done and the only page limitation is the size of your hard drive. All of the other alternatives" & _
                      " for print preview that I could think of crash at about 45 pages because" & _
                      " of memory limitations.  All printing locations are entered in inches" & _
                      " (or centimeters depending on the setting in Class_Initialize); no more tab(??).", 0.75

    cPrint.pQuarterSpace
    cPrint.pPrint "For example, this line started printing 1.09 inches from the left margin. " & _
                  "The default scale mode is inches; you can change the default scale mode by " & _
                  "modifying the oScaleMode variable in the class's Class_Initialize sub.", 1.09

    cPrint.FontItalic = True
    cPrint.pHalfSpace
    cPrint.pPrint "Preview functions include:", 1.25
    cPrint.FontItalic = False
    cPrint.pBullet 1.5
    cPrint.pPrint "Horizontal and vertical scroll bars appear as required.  Use these to move the page around the screen or just click and drag the page with your mouse.  You can also use the arrow keys."
    cPrint.pBullet 1.5
    cPrint.pPrint "Print current page, a range of pages, all pages, or copy the page to the clipboard."
    cPrint.pBullet 1.5
    cPrint.pPrint "Move forward or backward through the pages."
    cPrint.pBullet 1.5
    cPrint.pPrint "Go to a specific page."
    cPrint.pBullet 1.5
    cPrint.pPrint "Fit page to screen (click the button again to restore the view)."
    cPrint.pHalfSpace
    cPrint.FontItalic = True
    cPrint.pPrint "Preview weaknesses:", 1.25
    cPrint.FontItalic = False
    cPrint.pBullet 1.5
    cPrint.pPrint "The preview may not always match the printed page; one may have a line or two more then the other."
    cPrint.pBullet 1.5
    cPrint.pPrint "When selecting a print option other then All, the printed page does not look as sharp as it does when you print all.  Also, you can not print double sided."
    cPrint.pPrint
    cPrint.pPrint "I did not add any zoom functionally; the preview is already large enough to see and I have spent far more time on this then I intended.  You can add this functionality by adding a second picture box and do the scaling using API StretchBlt or picturebox.PaintPicture function (see the PrintPictureBox sub in the frmMultiPgPreview form).", 0.75
    cPrint.pPrint
    cPrint.pPrint "I hope you find this code useful; please e-mail me if you have any suggestions on how to improve it.", 0.75
    cPrint.pPrint
    cPrint.pPrint "Cordially,", 1
    cPrint.pPrint "Morgan Haueisen", 1
    cPrint.FontUnderline = True
    cPrint.ForeColor = vbBlue
    cPrint.pPrint "morganh@hartcom.net", 1
    cPrint.pPrint
    cPrint.FontUnderline = False
    cPrint.ForeColor = vbBlack
    cPrint.pPrint "To view all the projects I have submitted go to:", 0.75
    cPrint.FontSize = 8
    cPrint.FontUnderline = True
    cPrint.ForeColor = vbBlue
    cPrint.FontName = "Arial"
    cPrint.pPrint "http://www.planetsourcecode.com/vb/scripts/BrowseCategoryOrSearchResults.asp?lngWId=1&blnAuthorSearch=TRUE&lngAuthorId=885253927&strAuthorName=Morgan%20Haueisen&txtMaxNumberOfEntriesPerPage=25", 1
    cPrint.FontUnderline = False
    cPrint.p15Space
    cPrint.pFontName
    cPrint.ForeColor = vbRed
    cPrint.FontBold = True
    cPrint.FontSize = 11
    cPrint.pPrint "Scroll down and check out the footer.", 1
    cPrint.pPrint "For additional printing examples, please see the last page.", 1
    cPrint.ForeColor = vbBlack
    cPrint.FontBold = False
    cPrint.pPrint
    cPrint.pPrint "Download a project that uses this print-preview code at: ", 0.5
    cPrint.ForeColor = vbBlue
    cPrint.FontUnderline = True
    cPrint.FontSize = 8
    cPrint.FontName = "Arial"
    cPrint.pPrint "http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=37077&lngWId=1", 0.75
    cPrint.pFontName
    cPrint.FontUnderline = False
    cPrint.ForeColor = vbBlack
    cPrint.pPrint

    cPrint.pFooter


    '/* Page 3 ***********************************************************************************
    cPrint.pNewPage
    cPrint.pPrint
    cPrint.FontSize = 12
    cPrint.FontBold = True
    cPrint.pPrint "Printing and Print Preview Help  ", 0.5, True
    cPrint.FontSize = 10
    cPrint.FontBold = False
    cPrint.pPrint "(all the printing coordinates are in inches.)"
    cPrint.pPrint
    cPrint.pDoubleLine
    cPrint.FontSize = 12
    cPrint.FontBold = True
    cPrint.pPrint
    cPrint.FontName = "Arial"
    cPrint.pPrint "Printing:", 0.5
    cPrint.pHalfSpace
    cPrint.FontBold = False
    cPrint.FontSize = 9

    cPrint.pBox 1, , cPrint.GetPaperWidth - 2, , &HFFFFD0, , vbFSSolid
    cPrint.pPrint "pStartDoc", C1, True
    cPrint.pPrint "start a document", C2

    cPrint.pPrint "pEndDoc", C1, True
    cPrint.pPrint "end a document", C2

    cPrint.pBox 1, , cPrint.GetPaperWidth - 2, , &HFFFFD0, , vbFSSolid
    cPrint.pPrint "p15Space", C1, True
    cPrint.pPrint "print a Line feed that is 1-1/2 times your current Font Size", C2

    cPrint.pPrint "pBox", C1, True
    cPrint.pPrint "print a box  (open or filled)", C2

    cPrint.pBox 1, , cPrint.GetPaperWidth - 2, , &HFFFFD0, , vbFSSolid
    cPrint.pPrint "pCancled", C1, True
    cPrint.pPrint "print the words '**** PRINTING CANCLED ****'", C2

    cPrint.pPrint "pCenter", C1, True
    cPrint.pPrint "print the text centered on the page ", C2, True
    cPrint.FontSize = 8
    cPrint.pPrint "(uses pCenterMultiLine when necessary)"
    cPrint.FontSize = 9

    cPrint.pBox 1, , cPrint.GetPaperWidth - 2, , &HFFFFD0, , vbFSSolid
    cPrint.pPrint "pCircle", C1, True
    cPrint.pPrint "print a circle (open or filled)", C2

    cPrint.pPrint "pDots", C1, True
    cPrint.pPrint "print dots from your current position, you pick the end point", C2

    cPrint.pBox 1, , cPrint.GetPaperWidth - 2, , &HFFFFD0, , vbFSSolid
    cPrint.pPrint "pDoubleLine", C1, True
    cPrint.pPrint "print a double line", C2

    cPrint.pPrint "pEndOfPage", C1, True
    cPrint.pPrint "check to see if you are close to the end of the page", C2

    cPrint.pBox 1, , cPrint.GetPaperWidth - 2, , &HFFFFD0, , vbFSSolid
    cPrint.pPrint "pFontName", C1, True
    cPrint.pPrint "change the printing font, if no font name is supplied, the default is Times New Roman", C2

    cPrint.pPrint "pFooter", C1, True
    cPrint.pPrint "print date, time, and page number at the bottom of the page", C2

    cPrint.pBox 1, , cPrint.GetPaperWidth - 2, , &HFFFFD0, , vbFSSolid
    cPrint.pPrint "pHalfSpace", C1, True
    cPrint.pPrint "print a Line feed at 1/2 your current Font Size", C2

    cPrint.pPrint "pLine", C1, True
    cPrint.pPrint "print a Line, ", C2, True
    cPrint.FontSize = 8
    cPrint.pPrint "(if lineweight=0 then the DrawWidth value is used.)"
    cPrint.FontSize = 9

    cPrint.pBox 1, , cPrint.GetPaperWidth - 2, , &HFFFFD0, , vbFSSolid
    cPrint.pPrint "pMultiline", C1, True
    cPrint.pPrint "split a long string into several printed lines.  You provide the left and right margins.", C2

    cPrint.pPrint "pNewPage", C1, True
    cPrint.pPrint "start a new page", C2

    cPrint.pBox 1, , cPrint.GetPaperWidth - 2, , &HFFFFD0, , vbFSSolid
    cPrint.pPrint "pPrint", C1, True
    cPrint.pPrint "print a string (uses pMultiline when necessary)", C2

    cPrint.pPrint "pPrintedDate", C1, True
    cPrint.pPrint "print Printed: And today 's date and time", C2

    cPrint.pBox 1, , cPrint.GetPaperWidth - 2, , &HFFFFD0, , vbFSSolid
    cPrint.pPrint "pQuarterSpace", C1, True
    cPrint.pPrint "print a Line feed at 1/4 your current Font Size", C2

    cPrint.pPrint "pRightJust", C1, True
    cPrint.pPrint "right justifies your text string", C2

    cPrint.pBox 1, , cPrint.GetPaperWidth - 2, , &HFFFFD0, , vbFSSolid
    cPrint.pPrint "pRightTab", C1, True
    cPrint.pPrint "print text using the right margin as the starting point, moving left.", C2

    cPrint.pPrint "pSpaces", C1, True
    cPrint.pPrint "print spaces (used to print a colored stripe by changing the back color)", C2

    cPrint.pBox 1, , cPrint.GetPaperWidth - 2, , &HFFFFD0, , vbFSSolid
    cPrint.pPrint "pVerticalLine", C1, True
    cPrint.pPrint "print a vertical line on your page.", C2

    cPrint.pPrint "pPrintPicture", C1, True
    cPrint.pPrint "print a picture at a specified location and size or fit to page", C2

    cPrint.pBox 1, , cPrint.GetPaperWidth - 2, , &HFFFFD0, , vbFSSolid
    cPrint.pPrint "pHeader", C1, True
    cPrint.pPrint "print a 1 or 2 line header at the top of the page.", C2

    cPrint.pPrint "pCenterMultiLine", C1, True
    cPrint.pPrint "split a long string into several centered lines.  You provide the left and right margins.", C2

    cPrint.pBox 1, , cPrint.GetPaperWidth - 2, , &HFFFFD0, , vbFSSolid
    cPrint.pPrint "pBullet", C1, True
    cPrint.pPrint "print a bullet character", C2

    cPrint.pPrint "pPrintRotate", C1, True
    cPrint.pPrint "print text at any angle.", C2

    cPrint.pPrint
    cPrint.pPrint
    cPrint.pFontName
    cPrint.FontSize = 11
    cPrint.ForeColor = vbRed
    cPrint.pPrint "Uses pBox to print a light blue box around every other line.", 0.5
    cPrint.ForeColor = vbBlack

    cPrint.pFooter


    '/* Page 4 *************************************************************************
    cPrint.pNewPage

⌨️ 快捷键说明

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