'**********************************************************************
'** Method of printing using PEprintgraphEx.
'** Assume two controls, Pego1 and Pe3do1 are to be printed
'** on one page with other text or graphics.
'**********************************************************************
'// If image is monochrome, BitmapGradientMode = False, then
'// setting PrintDpi = 0 may be preferred.
'// Optionally use or comment out this section
Printer.ScaleMode = vbInches
Dim fInchesX As Single
Dim fInchesY As Single
fInchesX = Printer.ScaleWidth
fInchesY = Printer.ScaleHeight
Printer.ScaleMode = vbPixels
Dim fPixelsX As Single
Dim fPixelsY As Single
fPixelsX = Printer.ScaleWidth
fPixelsY = Printer.ScaleHeight
Dim nDpiX As Integer
Dim nDpiY As Integer
nDpiX = fPixelsX / fInchesX
nDpiY = fPixelsY / fInchesY
Pego1.PrintDpi = 0
Pe3do1.PrintDpi = 0
Pego1.DpiX = nDpiX '// Setting Dpi makes for consistent font sizes between
Pego1.DpiY = nDpiY '// different printers.
Pe3do1.DpiX = nDpiX
Pe3do1.DpiY = nDpiY
'// change to monochome mode //
Pego1.ViewingStyle = PEVS_MONO
Pe3do1.ViewingStyle = PEVS_MONO
Dim hRes As Long
Dim vRes As Long
Dim nOrgX As Long
Dim nOrgY As Long
Dim nExtX As Long
Dim nExtY As Long
Printer.Orientation = 1
'** get size of page, ProEssentials want units of 1/100th millimeter **'
Printer.ScaleMode = vbMillimeters
vRes = Printer.ScaleHeight * 100
hRes = Printer.ScaleWidth * 100
'// Print something so VB knows something was sent to printer //
Printer.Print " "
'// first image //'
nOrgX = 0
nOrgY = 0
nExtX = hRes * 0.5
nExtY = vRes * 0.5
Call Pego1.PEprintgraphEx(Printer.hDC, nExtX, nExtY, nOrgX, nOrgY)
'// second image //
nOrgX = hRes * 0.5
nOrgY = vRes * 0.5
nExtX = hRes * 0.5
nExtY = vRes * 0.5
Call Pe3do1.PEprintgraphEx(Printer.hDC, nExtX, nExtY, nOrgX, nOrgY)
Printer.EndDoc
'// Reset to color mode //
Pego1.ViewingStyle = PEVS_COLOR
Pe3do1.ViewingStyle = PEVS_COLOR
Pego1.PEactions = REINITIALIZE_RESETIMAGE
Pe3do1.PEactions = REINITIALIZE_RESETIMAGE
'**********************************************************************
'** Lowest level approach to printing, playing metafile.
'** Above code does the same thing for you when
'** PrintDpi = 0
'**********************************************************************
Dim hMeta, hRes, vRes, OldMM, lresult As Long
Dim nOrgX, nOrgY, nExtX, nExtY, hRgn As Long
Dim pt As POINTSTRUCT ' defined in "PE5API.BAS"
'** send printer something so VB knows to start page **'
Printer.Print " "
'** get size of page **'
Printer.ScaleMode = 3 ' pixels
hRes = Printer.ScaleWidth
vRes = Printer.ScaleHeight
'** set mapping mode MM_TEXT **'
oldMM = SetMapMode(Printer.hdc, 1)
'// first image //
'** Set viewport org and extents **'
nOrgX = hRes * 0
nOrgY = vRes * 0
nExtX = hRes * 0.5
nExtY = vRes * 0.5
lresult = SetViewportOrgEx(Printer.hdc, nOrgX, nOrgY, pt)
lresult = SetViewportExtEx(Printer.hdc, nExtX, nExtY, pt)
'** Create Clipping Region **'
hRgn = CreateRectRgn(nOrgX, nOrgY, nExtX + nOrgX, nExtY + nOrgY)
lresult = SelectClipRgn(Printer.hdc, hRgn)
lresult = DeleteObject(hRgn)
'** reset image shape to match shape defined by SetViewportExt **'
Pego1.PEresetimageEx nExtX, nExtY, nOrgX, nOrgY
hMeta = Pego1.PEgetmeta
lresult = PEplaymetafile(Pego1, Printer.hdc, hMeta)
'// second image //
'** Set viewport org and extents **'
nOrgX = hRes * 0.5
nOrgY = vRes * 0.5
nExtX = hRes * 0.5
nExtY = vRes * 0.5
lresult = SetViewportOrgEx(Printer.hdc, nOrgX, nOrgY, pt)
lresult = SetViewportExtEx(Printer.hdc, nExtX, nExtY, pt)
'** Create Clipping Region **'
hRgn = CreateRectRgn(nOrgX, nOrgY, nExtX + nOrgX, nExtY + nOrgY)
lresult = SelectClipRgn(Printer.hdc, hRgn)
lresult = DeleteObject(hRgn)
'** reset image shape to match shape defined by SetViewportExt **'
Pe3do1.PEresetimageEx nExtX, nExtY, nOrgX, nOrgY
hMeta = Pe3do1.PEgetmeta
lresult = PEplaymetafile(Pe3do1, Printer.hdc, hMeta)
Printer.EndDoc
' ** reset mapping mode **'
lresult = SetMapMode(Printer.hdc, oldMM)
' ** reset image to current aspect ratio **'
Pego1.PEresetimage 0, 0
Pe3do1.PEresetimage 0, 0
|