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

📄 form1.frm

📁 打印预览程序
💻 FRM
📖 第 1 页 / 共 3 页
字号:
    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 "Properties (Set or Get):", 0.5
    cPrint.pHalfSpace
    cPrint.FontBold = False
    cPrint.FontSize = 9

    memCurrentYt = cPrint.CurrentY + 0.03 '/* remember starting point for vertical lines

    cPrint.pLine C0, C3, 4
    cPrint.pPrint "CurrentX", C1, True
    cPrint.pPrint "current X position", C2

    cPrint.pLine C0, C3, 4
    cPrint.pPrint "CurrentY", C1, True
    cPrint.pPrint "current Y position", C2

    cPrint.pLine C0, C3, 4
    cPrint.pPrint "DrawWidth", C1, True
    cPrint.pPrint "for printing boxes and circles", C2

    cPrint.pLine C0, C3, 4
    cPrint.pPrint "FontBold", C1, True
    cPrint.pPrint "bold Font", C2

    cPrint.pLine C0, C3, 4
    cPrint.pPrint "FontItalic", C1, True
    cPrint.pPrint "italic Font", C2

    cPrint.pLine C0, C3, 4
    cPrint.pPrint "FontName", C1, True
    cPrint.pPrint "font name (this is different then pFontName in that you must supply a font name)", C2

    cPrint.pLine C0, C3, 4
    cPrint.pPrint "FontSize", C1, True
    cPrint.pPrint "font Size", C2

    cPrint.pLine C0, C3, 4
    cPrint.pPrint "FontStrikethru", C1, True
    cPrint.pPrint "strike through font", C2

    cPrint.pLine C0, C3, 4
    cPrint.pPrint "FontTransparent", C1, True
    cPrint.pPrint "changes the font's background", C2

    cPrint.pLine C0, C3, 4
    cPrint.pPrint "FontUnderline", C1, True
    cPrint.pPrint "underline Font", C2

    cPrint.pLine C0, C3, 4
    cPrint.pPrint "ForeColor", C1, True
    cPrint.pPrint "font's foreground color", C2

    cPrint.pLine C0, C3, 4
    cPrint.pPrint "BackColor", C1, True
    cPrint.pPrint "font's background color, setting it to -1 is the same as setting FontTransparent = True", C2

    cPrint.pLine C0, C3, 4
    cPrint.pPrint "Orientation", C1, True
    cPrint.pPrint "printer 's orientation (portrait or landscape)", C2

    cPrint.pLine C0, C3, 4
    cPrint.pPrint "PrintCopies", C1, True
    cPrint.pPrint "how many copies the printer will print", C2

    cPrint.pLine C0, C3, 4
    cPrint.pPrint "SendToPrinter", C1, True
    cPrint.pPrint "determines if the output goes to the printer or the screen", C2

    memCurrentYb = cPrint.CurrentY + 0.03 '/* remember ending point for vertical lines

    cPrint.pLine C0, C3, 4
    cPrint.pVerticalLine C0, memCurrentYt, memCurrentYb, 4
    cPrint.pVerticalLine C2 - 0.1, memCurrentYt, memCurrentYb, 4
    cPrint.pVerticalLine C3, memCurrentYt, memCurrentYb, 4

    cPrint.pPrint
    cPrint.pPrint
    cPrint.pFontName
    cPrint.FontSize = 11
    cPrint.ForeColor = vbRed
    cPrint.pPrint "Uses pLine and pVerticalLine to draw the grid with a line weight = 4.", 0.5
    cPrint.ForeColor = vbBlack

    cPrint.pFooter


    '/* Page 5 *********************************************************************************
    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

    '/* Show Grid Option #1
    cPrint.FontSize = 12
    cPrint.FontBold = True
    cPrint.pPrint
    cPrint.FontName = "Arial"
    cPrint.pPrint "Functions:", 0.5
    cPrint.pHalfSpace
    cPrint.FontBold = False
    cPrint.FontSize = 9
    cPrint.FontTransparent = True

    memCurrentYt = cPrint.CurrentY + 0.03 '/* remember starting point for vertical lines

    cPrint.pLine C0, cPrint.GetPaperWidth - 1
    cPrint.pBox 1, , cPrint.GetPaperWidth - 2, , &HC0FFFF, , vbFSSolid
    cPrint.pPrint "GetFormalCase", C1, True
    cPrint.pPrint "returns the formal case of a string", C2

    cPrint.pLine C0, cPrint.GetPaperWidth - 1
    cPrint.pPrint "GetPage", C1, True
    cPrint.pPrint "returns the current page number", C2

    cPrint.pLine C0, cPrint.GetPaperWidth - 1
    cPrint.pBox 1, , cPrint.GetPaperWidth - 2, , &HC0FFFF, , vbFSSolid
    cPrint.pPrint "GetPaperHeight", C1, True
    cPrint.pPrint "returns the printer's printable area (height in inches)", C2

    cPrint.pLine C0, cPrint.GetPaperWidth - 1
    cPrint.pPrint "GetPaperWidth", C1, True
    cPrint.pPrint "returns the printer's printable area (width in inches)", C2

    cPrint.pLine C0, cPrint.GetPaperWidth - 1
    cPrint.pBox 1, , cPrint.GetPaperWidth - 2, , &HC0FFFF, , vbFSSolid
    cPrint.pPrint "GetTextWidth", C1, True
    cPrint.pPrint "returns the width of a text string in inches", C2

    cPrint.pLine C0, cPrint.GetPaperWidth - 1
    cPrint.pPrint "GetStripQuotes", C1, True
    cPrint.pPrint "removes the quotes from the beginning and end of a text string", C2

    cPrint.pLine C0, cPrint.GetPaperWidth - 1
    cPrint.pBox 1, , cPrint.GetPaperWidth - 2, , &HC0FFFF, , vbFSSolid
    cPrint.pPrint "GetRemoveCRLF", C1, True
    cPrint.pPrint "removes all line feeds imbedded in a string", C2

    memCurrentYb = cPrint.CurrentY + 0.03 '/* remember ending point for vertical lines

    cPrint.pLine C0, cPrint.GetPaperWidth - 1
    cPrint.pVerticalLine C0, memCurrentYt, memCurrentYb
    cPrint.pVerticalLine C2 - 0.1, memCurrentYt, memCurrentYb
    cPrint.pVerticalLine cPrint.GetPaperWidth - 1, memCurrentYt, memCurrentYb

    cPrint.pPrint
    cPrint.pPrint
    cPrint.pFontName
    cPrint.FontSize = 11
    cPrint.ForeColor = vbRed
    cPrint.pPrint "Uses pLine and pVerticalLine to draw the grid with a line weight = 1 and pBox to draw the colored background.", 0.5
    cPrint.ForeColor = vbBlack

    cPrint.p15Space
    cPrint.p15Space

    '/* Show Grid Option #2
    cPrint.FontSize = 12
    cPrint.FontBold = True
    cPrint.pPrint
    cPrint.FontName = "Arial"
    cPrint.pPrint "Functions:", 0.5
    cPrint.pHalfSpace
    cPrint.FontBold = False
    cPrint.FontSize = 9
    cPrint.FontTransparent = True

    memCurrentYt = cPrint.CurrentY '/* remember starting point for vertical lines

    cPrint.pBox 1, , cPrint.GetPaperWidth - 2, , , &HC0FFFF, vbFSSolid
    cPrint.pPrint "GetFormalCase", C1, True
    cPrint.pPrint "returns the formal case of a string", C2

    cPrint.pPrint "GetPage", C1, True
    cPrint.pPrint "returns the current page number", C2

    cPrint.pBox 1, , cPrint.GetPaperWidth - 2, , , &HC0FFFF, vbFSSolid
    cPrint.pPrint "GetPaperHeight", C1, True
    cPrint.pPrint "returns the printers printable area (height in inches)", C2

    cPrint.pPrint "GetPaperWidth", C1, True
    cPrint.pPrint "returns the printers printable area (width in inches)", C2

    cPrint.pBox 1, , cPrint.GetPaperWidth - 2, , , &HC0FFFF, vbFSSolid
    cPrint.pPrint "GetTextWidth", C1, True
    cPrint.pPrint "returns the width of a text string in inches", C2

    cPrint.pPrint "GetStripQuotes", C1, True
    cPrint.pPrint "removes the quotes from the beginning and end of a text string", C2

    cPrint.pBox 1, , cPrint.GetPaperWidth - 2, , , &HC0FFFF, vbFSSolid
    cPrint.pPrint "GetRemoveCRLF", C1, True
    cPrint.pPrint "removes all line feeds imbedded in a string", C2

    memCurrentYb = cPrint.CurrentY '/* remember ending point for vertical lines

    cPrint.pVerticalLine C0, memCurrentYt, memCurrentYb
    cPrint.pVerticalLine C2 - 0.1, memCurrentYt, memCurrentYb
    cPrint.pVerticalLine cPrint.GetPaperWidth - 1, memCurrentYt, memCurrentYb

    cPrint.pPrint
    cPrint.pPrint
    cPrint.pFontName
    cPrint.FontSize = 11
    cPrint.ForeColor = vbRed
    cPrint.pPrint "Uses pVerticalLine and pBox to draw the colored background and grid.", 0.5
    cPrint.ForeColor = vbBlack

    cPrint.pFooter


    '/* Page 6 *********************************************************************************
    cPrint.pNewPage
    cPrint.pFontName
    cPrint.pHeader "MORE EXAMPLES"
    cPrint.p15Space
    cPrint.pPrint "Right justify a string", 1, True
    cPrint.pDots 4.3
    cPrint.pRightJust "45.00", 5
    cPrint.pPrint "Right justify again", 1, True
    cPrint.pDots 4.3
    cPrint.pRightJust "1,445.00", 5
    cPrint.pPrint "Right justify once more", 1, True
    cPrint.pDots 4.3
    cPrint.pRightJust "21,445.00", 5
    cPrint.pPrint
    cPrint.pRightTab "This text is 1.25 inches from the right margin.", 1.25
    cPrint.pRightTab "Print Portrait and Landscape to see the change.", 1.25
    
    cPrint.p15Space
    cPrint.p15Space
    cPrint.p15Space
    
    cPrint.pCircle 1, cPrint.CurrentY, 0.25, vbBlue
    cPrint.DrawWidth = 6
    cPrint.pCircle 2, cPrint.CurrentY, 0.25, vbBlue
    cPrint.pCircle 3, cPrint.CurrentY, 0.25, vbBlue, vbRed, vbFSSolid
    cPrint.DrawWidth = 1
    cPrint.pCircle 4, cPrint.CurrentY, 0.25, vbBlue, vbRed, vbCross
    cPrint.pCircle 5, cPrint.CurrentY, 0.25, vbBlue, , vbDownwardDiagonal, 1.5
    cPrint.pCircle 6, cPrint.CurrentY, 0.25, vbBlue, , vbDownwardDiagonal, 0.5
        
    cPrint.p15Space
    cPrint.pBox 1, 3, 1, 1, vbGreen
    cPrint.pBox 3, 3, 1, 1, vbGreen, QBColor(13), vbFSSolid
    cPrint.pBox 5, 3, 2, 1, vbGreen, QBColor(7), vbUpwardDiagonal
        
    cPrint.CurrentY = 3.25
    cPrint.pPrint " Box ", 1.35, True
    cPrint.BackColor = vbWhite
    cPrint.pPrint " Box ", 3.35, True
    cPrint.pPrint " Box ", 5.35
    cPrint.pPrint
    cPrint.BackColor = -1
    cPrint.pPrint " Box ", 1.35, True
    cPrint.pPrint " Box ", 3.35, True
    cPrint.pPrint " Box ", 5.35
    
    cPrint.CurrentY = 4.1
    cPrint.FontSize = 12
    cPrint.pPrint "An example of highlighted text:", 1
    cPrint.pPrint "This is ", 1, True
    cPrint.BackColor = vbYellow
    cPrint.ForeColor = vbRed
    cPrint.pPrint "My Son", , True
    cPrint.BackColor = -1
    cPrint.ForeColor = vbBlack
    cPrint.pPrint " who is 2.5 years old."
    
    cPrint.pPrintPicture LoadPicture(App.Path & "\myson.jpg"), 1, 4.5, 3
    cPrint.pPrintPicture LoadPicture(App.Path & "\myson.jpg"), 4, 6, 1
    
    memCurrentYt = cPrint.CurrentY
    cPrint.pMultiline "This text uses pMultiline to print text between two user specified margins.  In this case it starts printing at 3.75 inches from the left margin and is 2 inches wide.", 3.75, 5.75
    
    cPrint.CurrentY = memCurrentYt
    cPrint.pCenterMultiline "This text uses pCenterMultiline to print text between two user specified margins.  In this case it starts printing at 6 inches from the left margin and is 1.5 inches wide.", 6, 7.5, True
    
    cPrint.FontBold = True
    cPrint.FontSize = 16
    cPrint.pPrintRotate "Print Preview - Rotate String", 90
    
    cPrint.FontBold = False
    cPrint.CurrentY = 7.5
    cPrint.FontSize = 12
    cPrint.pPrintRotate "Print Preview - Rotate String", 45, 4.5
    
    picPrinting.Visible = False
    Screen.MousePointer = vbDefault
    
    cPrint.ReportTitle = Command1.Caption
    
    cPrint.pFooter
    cPrint.pEndDoc
    
    If cPrint.SendToPrinter Then GoTo SendToPrinter
    
    Set cPrint = Nothing
    
End Sub


Private Sub Command2_Click()
  Dim i As Integer
    
    Set cPrint = New clsMultiPgPreview
    
    With frmPrinterSetUp
        .fraOrientation.Visible = False
        .cmdPrint.Visible = False
        .Show vbModal
    End With
    If QuitCommand Then
        Set cPrint = Nothing
        Exit Sub
    End If
    
    cPrint.Orientation = PageLandscape
    cPrint.SendToPrinter = False
    
    picPrinting.Visible = True
    MousePointer = vbHourglass
    DoEvents

SendToPrinter:
    cPrint.pStartDoc
    
    cPrint.FontSize = 11
    GoSub PrintHeader
    
    cPrint.pPrint "cPrint.Orientation = PageLandscape", 0.5
    cPrint.pPrint "cPrint.SendToPrinter = False", 0.5
    cPrint.pPrint
    
    Do
        i = i + 1
        cPrint.pRightJust CStr(i), 1, True
        cPrint.pPrint "This line is printed over and over again", 1.1, True
        cPrint.pPrint "At 5 Inches", 5, True
        cPrint.pPrint "At 7 Inches", 7, True
        cPrint.pRightJust "RightJust " & CStr(i), 9.5
        
        If cPrint.pEndOfPage Then
            If cPrint.GetPage = 4 Then Exit Do
            cPrint.pFooter
            cPrint.pNewPage
            GoSub PrintHeader
        End If
    Loop
    cPrint.pFooter
    
    picPrinting.Visible = False
    MousePointer = vbDefault
    
    cPrint.pEndDoc
    If cPrint.SendToPrinter Then GoTo SendToPrinter
    Set cPrint = Nothing
    
Exit Sub
    
PrintHeader:
    cPrint.pHeader "EndOfPage Check Demo", "(print some junk that runs across several pages)"
Return
    
End Sub

Private Sub Command3_Click()
  Dim tString  As String
  
    tString = "This" & vbCrLf & "is" & vbLf & vbCr & "a" & vbCrLf & "Test"
    
    Set cPrint = New clsMultiPgPreview
    
    frmPrinterSetUp.Show vbModal
    If QuitCommand Then
        Set cPrint = Nothing
        Exit Sub
    End If

    
SendToPrinter:
    picPrinting.Visible = True
    
    cPrint.pStartDoc
    cPrint.pHeader "Ignore CF and LF", , False
    cPrint.FontSize = 12
    cPrint.CurrentY = 1
    cPrint.pPrint "Print a text string with imbedded CRLF characters and still keep the user specified left margin.", 0.75
    cPrint.pPrint
    cPrint.pPrint "Example:", 1.5
    cPrint.pPrint
    cPrint.pPrint tString, 2
    cPrint.pPrint
    cPrint.pPrint
    cPrint.pPrint "Or strip the imbedded characters to make a single line.", 0.75
    cPrint.pPrint
    cPrint.pPrint "Example:", 1.5
    cPrint.pPrint
    cPrint.pPrint cPrint.GetRemoveCRLF(tString), 2
    
    picPrinting.Visible = False
    cPrint.pFooter
    cPrint.pEndDoc
    If cPrint.SendToPrinter Then GoTo SendToPrinter
    Set cPrint = Nothing
End Sub

⌨️ 快捷键说明

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