Trojan Lord » 17.04.2003 (Чт) 15:13
Автор: незнаю
Модуль:
Option Explicit
Public HorizontalMargin, VerticalMargin As Single
'----------------------------------
'Setup Printer
'This is needed for most of the
'procedures and functions in this
'module to work.
'----------------------------------
Public Sub SetupPrinter()
'Set printer's scale to centimeters
Printer.ScaleMode = vbCentimeters
'Set paper margin
HorizontalMargin = 1 + ((21 - Printer.ScaleWidth) / 2)
VerticalMargin = 1.5 + ((29.7 - Printer.ScaleHeight) / 2)
End Sub
'----------------------------------
'Quick Print
'----------------------------------
Public Sub QuickPrint(strPrintText)
Printer.Print "";
Printer.Print strPrintText
Printer.EndDoc
End Sub
'----------------------------------
'Easily reset font types and sizes
'----------------------------------
Public Sub SetFont(size As Integer, b, i, u, s As Boolean)
With Printer
'Set the fonts
.ForeColor = RGB(0, 0, 0) 'Black color
'Making Arial font type the default font
.FontName = "Arial"
'These are all variables
.FontSize = size
.FontBold = b
.FontItalic = i
.FontUnderline = u
.FontStrikethru = s
End With
End Sub
'------------------------
'Justify center
'-------------------------
Public Sub AlignCenter(ByVal strText As String)
Printer.CurrentX = ((Printer.ScaleWidth - Printer.TextWidth(strText)) / 2)
End Sub
'------------------------
'Justify right
'-------------------------
Public Sub AlignRight(ByVal strText As String)
Printer.CurrentX = Printer.ScaleWidth - 2
End Sub
'------------------------
'Justify left
'-------------------------
Public Sub AlignLeft(ByVal strText As String)
Printer.CurrentX = Printer.CurrentX + 2
End Sub
'-------------------------
'Get Current X
'-------------------------
Public Function GetX() As Single
GetX = Printer.CurrentX
End Function
'-------------------------
'Get current Y
'-------------------------
Public Function GetY() As Single
GetY = Printer.CurrentY
End Function
'------------------------
'Print line
'-------------------------
Public Sub PrintLine(Optional LeftPos As Single = 0)
Printer.Line (LeftPos, Printer.CurrentY)-(Printer.ScaleWidth, Printer.CurrentY)
End Sub
'-------------------
'Check Page length
'-------------------
Public Sub CheckPageLen()
If EndOfPage Then
Printer.NewPage
End If
End Sub
'------------------------
'Check for End-of-Page
'-------------------------
Public Function EndOfPage() As Boolean
Dim n As Single
n = Printer.ScaleHeight - 2
If Printer.CurrentY = n Then EndOfPage = True
End Function
'-------------------------------------------------------------
'Print header/footer/page number
'-------------------------------------------------------------
Public Sub PrintHeader(strheader As String)
Printer.CurrentY = VerticalMargin - 1
Printer.CurrentX = HorizontalMargin
Printer.Print "";
SetFont 36, True, True, True, False
pCenter strheader
Printer.Print strheader
Printer.EndDoc
End Sub
Public Sub PrintFooter(strfooter As String)
Printer.CurrentY = Printer.ScaleHeight - 1.5
Printer.CurrentX = HorizontalMargin
Printer.Print "";
SetFont 12, False, False, False, False
pCenter strfooter
Printer.Print strfooter
Printer.EndDoc
End Sub
Public Sub PrintPageNum(PageNum As String)
With Printer
.CurrentY = Printer.ScaleHeight - 0.5
.CurrentX = HorizontalMargin
End With
SetFont 10, False, False, False, False
pCenter PageNum
Printer.Print "";
Printer.Print PageNum
Printer.EndDoc
End Sub
Не важно на каком языке ты пишешь, главное - Алгоритм.