As _Offset lpszDocName
, lpszOutput
, lpszDatatype
As _Offset hwndOwner
, hDevMode
, hDevNames
, hDC
As Integer nFromPage
, nToPage
, nMinPage
, nMaxPage
, nCopies
As _Offset hInstance
, lCustData
, lpfnPrintHook
, lpfnSetupHook
, lpPrintTemplateName
, lpSetupTemplateName
, hPrintTemplate
, hSetupTemplate
Function CreateFont%&
Alias "CreateFontA" (ByVal cHeight
As Long, Byval cWidth
As Long, Byval cEscapement
As Long, Byval cOrientation
As Long, Byval cWeight
As Long, Byval bItalic
As _Unsigned Long, Byval bUnderline
As _Unsigned Long, Byval bStrikeout
As _Unsigned Long, Byval iCharSet
As _Unsigned Long, Byval iOutPrecision
As _Unsigned Long, Byval iClipPrecision
As _Unsigned Long, Byval iQuality
As _Unsigned Long, Byval iPitchAndFamily
As _Unsigned Long, pszFaceName
As String)
Declare Library ".\internal\c\c_compiler\x86_64-w64-mingw32\include\wingdi" Declare Library ".\internal\c\c_compiler\i686-w64-mingw32\include\wingdi" PrintJob
docname
= docname
+ Chr$(0)
nWidth = GetDeviceCaps(hdc, HORZRES)
nHeight = GetDeviceCaps(hdc, VERTRES)
'SelectObject hdc, CreatePen(PS_SOLID, 2, RGB(255, 0, 0))
'Rectangle hdc, 0, 0, nWidth - 4, nHeight - 2
SetBkMode hdc, TRANSPARENT
t1 = "Title!"
t2 = "This is another print test!"
HDCPrint hdc, t1, "Castellar", 72, "UNDERLINE", "BLACK", 425, 550, RGB(188, 33, 116)
HDCPrint hdc, t2, "Freestyle Script", 48, "UNDERLINE", "BLACK", 425, 750, RGB(33, 127, 127)
HDCPrint hdc, t3, "Goudy Stout", 24, "", "BLACK", 425, 1100, RGB(127, 55, 127)
AbortProc = -1
Const PD_RETURNDC
= &H100 pdlg.lStructSize
= Len(pdlg
) pdlg.Flags = PD_RETURNDC
pdlg.nMinPage = 1
pdlg.nMaxPage = Pages
pdlg.nToPage = Pages
GetPrinterDC = pdlg.hDC
Const MB_APPLMODAL
= &H00000000 hDC = GetPrinterDC(2)
MessageBox
0, "Error creating DC" + Chr$(0), "Error" + Chr$(0), MB_APPLMODAL
Or MB_OK
If SetAbortProc
(hDC
, pAbortProc
) = SP_ERROR
Then MessageBox
0, "Error setting up AbortProc" + Chr$(0), "Error" + Chr$(0), MB_APPLMODAL
Or MB_OK
InitPrintJobDoc di, "MyDoc"
For l
= 1 To pdlg.nCopies
For i
= 1 To pdlg.nToPage
StartPage hDC
DrawPage hDC, i
EndPage hDC
EndDoc hDC
DeleteDC hDC
weight = 100
Case "EXTRALIGHT", "ULTRALIGHT" weight = 200
weight = 300
weight = 400
weight = 500
Case "SEMIBOLD", "DEMIBOLD" weight = 600
weight = 700
Case "EXTRABOLD", "ULTRABOLD" weight = 800
weight = 900
weight = 0
Const DT_CALCRECT
= &H00000400 Dim As Long DPIScaleY: DPIScaleY
= GetDeviceCaps
(hdc
, LOGPIXELSY
) / 96 Dim As Long DPIScaleX: DPIScaleX
= GetDeviceCaps
(hdc
, LOGPIXELSX
) / 96 font
= CreateFont
(height
* DPIScaleY
, 0, 0, 0, weight
, italic
, underline
, strikeout
, 0, 0, 0, 5, FF_DECORATIVE
Or FF_MODERN
Or FF_ROMAN
Or FF_SCRIPT
Or FF_SWISS
, fontName
+ Chr$(0)) SelectObject hdc, font
SetTextColor hdc, colorref
GetTextExtentPoint32 hdc
, text
, Len(text
), _Offset(size
) If x
> 0 Then nx
= (x
* DPIScaleX
) - size.cx
/ 2 Else nx
= x
* DPIScaleX
If y
> 0 Then ny
= (y
* DPIScaleY
) - (size.cy
) Else ny
= y
* DPIScaleY