home *** CD-ROM | disk | FTP | other *** search
- '----------------------------------------------------------------
- 'Copyright 1994 Unger Business Systems All Rights Reserved
- 'This code is distributed as shareware. If you use it, you
- 'are required by law to register it. Please contact Unger
- 'Business Systems at 11926 Barrett Brae, Houston, TX 77072-4004
- 'or call (713) 498-8517. Registration fee is $20.00 US
- 'See the README.TXT file for more information
- '
- 'All code, forms, modules, controls, etc. are provided without
- 'warranty or liability
- '----------------------------------------------------------------
-
- Option Explicit
-
- Global Const MB_OK = 0 'Display OK button only.
- Global Const MB_OKCANCEL = 1 'Display OK and Cancel buttons.
- Global Const MB_ABORTRETRYIGNORE = 2 'Display Abort, Retry, and Ignore buttons.
- Global Const MB_YESNOCANCEL = 3 'Display Yes, No, and Cancel buttons.
- Global Const MB_YESNO = 4 'Display Yes and No buttons.
- Global Const MB_RETRYCANCEL = 5 'Display Retry and Cancel buttons.
-
- Global Const MB_ICONSTOP = 16
- Global Const MB_ICONQUESTION = 32
- Global Const MB_ICONEXCLAMATION = 48
- Global Const MB_ICONINFORMATION = 64
-
- Global Const MB_DEFBUTTON1 = 0 'First button is default.
- Global Const MB_DEFBUTTON2 = 256 'Second button is default.
- Global Const MB_DEFBUTTON3 = 512 'Third button is default.
-
- Global Const MB_APPLMODAL = 0 'Application modal. The user must respond to the
- 'message box before continuing work in the current application.
- Global Const MB_SYSTEMMODAL = 4096 'System modal. All applications are suspended until the
- 'user responds to the message box.
-
- Global Const IDOK = 1 'OK button selected.
- Global Const IDCANCEL = 2 'Cancel button selected.
- Global Const IDABORT = 3 'Abort button selected.
- Global Const IDRETRY = 4 'Retry button selected.
- Global Const IDIGNORE = 5 'Ignore button selected.
- Global Const IDYES = 6 'Yes button selected.
- Global Const IDNO = 7 'No button selected.
-
- Global ThisPrinter$, ThisOrientation$
-
- Sub PrintThisText (ByVal TextStr$, ByVal TFontName$, ByVal TFontSize!, ByVal UseBold%, ByVal UseItalic%)
- Dim prhdc%, di%, NumLines%, I%
-
- If Trim$(TFontName) = "" Then
- MsgBox "You must supply a font name.", MB_ICONSTOP
- Exit Sub
- End If
-
- If TFontSize < 6 Or TFontSize > 48 Then 'these values are arbitrary for this example
- MsgBox "Invalid font size.", MB_ICONSTOP
- Exit Sub
- End If
-
- prhdc = GenPrinterSetup(ThisPrinter, ThisOrientation)
- 'prhdc is an integer which now contains the device
- 'context for ThisPrinter. ThisPrinter is a string of the
- 'form "HP LaserJet IIP,HPPCL,LPT1:" as stored in the
- 'WIN.INI file. Note that prhdc is passed to virtually
- 'all of the other GENPRINT routines. This routine as
- 'written call DefaultFontSetup and uses "Ariel" font in
- '10 pt size.
-
- If prhdc = 0 Then 'call failed
- GoTo PrintThisTextErrHandler
- End If
-
- SetPrtFontName prhdc, GetOnlyFontName(TFontName)
- SetPrtFontSize prhdc, TFontSize
- SetPrtFontBold prhdc, UseBold
- SetPrtFontItalic prhdc, UseItalic
-
- SetupDocInfo ("VBG Printer")
- 'This supplies the information used by Print Manager.
-
- SetAbortCallback (prhdc)
- 'This sets up the abort procedure.
-
- ShowAbortForm (False) 'must not be system modal
- 'This displays the abort form.
-
- di = StartDocument(prhdc)
- 'This tells Print Manager that we are starting a document.
-
- di = StartAPage(prhdc)
- 'Start a page!
-
- NumLines = SplitLines(prhdc, TextStr, 5.5)
- 'Split TextStr into lines of not more than 5.5 inches
- 'Return number of lines generated
-
- SetTextY 1 'start printing 1 inch from top
-
- 'There are numerous other functions which can now be called to draw
- 'lines, rectangles, etc. The font can also be changed. See the
- 'GPRINTER.BAS module for available functions.
- For I = 1 To NumLines
- SetTextX .75 'start printing .75 inches from left margin
- PrintText prhdc, LinesArray(I)
- LineFeed prhdc
- Next I
-
- di = EndAPage(prhdc)
- 'This is called each time you want to end a page. If
- 'more pages are to be printed, be sure to call StartAPage
- 'again.
-
- di = EndDocument(prhdc)
- 'This tells Print Manager that the document is finished.
-
- UnloadAbortForm
- 'Get rid of the abort form.
-
- GenPrinterClose prhdc
- 'Clean up after printer. After this call prhdc is no
- 'longer valid.
-
- Exit Sub
-
- PrintThisTextErrHandler:
- MsgBox "Unable to create device context!", MB_ICONSTOP
- Exit Sub
- End Sub
-
-