Hallo
Ik ben bezig met een applicatie die 2 verticale teksten moet printen via de API. Nu was ik al heel blij dat ik dat op mijn HP6 aan de praat kreeg, ben niet zo'n API expert...
Het probleem is dat als ik het op een andere printer print (b.v Sharp AR 350 of HP5SI) de X van de verticale tekst anders is / er verkeerd wordt geprint.
API Masters please respond...
Bijvoorbaat dank,
Mike
Public Sub MakePrintApi()
' Combine API Calls with the Printer object
Dim OutString As String
Dim lf As LOGFONT
Dim result As Long
Dim hOldfont As Long
Dim hPrintDc As Long
Dim hFont As Long
hPrintDc = Printer.hdc
OutString = rtfData.Text
'DESIREDFONTSIZE = rtfData.Font.size
lf.lfFaceName = rtfData.Font.Name
lf.lfEscapement = 900
lf.lfHeight = (DESIREDFONTSIZE * -19.5) / Printer.TwipsPerPixelY
hFont = CreateFontIndirect(lf)
hOldfont = SelectObject(hPrintDc, hFont)
result = TextOut(hPrintDc, 155, 1600, OutString, Len(OutString))
result = TextOut(hPrintDc, 1880, 1600, OutString,
Len(OutString))
result = SelectObject(hPrintDc, hOldfont)
result = DeleteObject(hFont)
end sub
'Declaration section
Private Const LF_FACESIZE = 32
Private Type LOGFONT
lfHeight As Long
lfWidth As Long
lfEscapement As Long
lfOrientation As Long
lfWeight As Long
lfItalic As Byte
lfUnderline As Byte
lfStrikeOut As Byte
lfCharSet As Byte
lfOutPrecision As Byte
lfClipPrecision As Byte
lfQuality As Byte
lfPitchAndFamily As Byte
lfFaceName As String * LF_FACESIZE
End Type
Private Type DOCINFO
cbSize As Long
lpszDocName As String
lpszOutput As String
lpszDatatype As String
fwType As Long
End Type
Private Declare Function CreateFontIndirect Lib "gdi32" Alias _
"CreateFontIndirectA" (lpLogFont As LOGFONT) As Long
Private Declare Function SelectObject Lib "gdi32" _
(ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" _
(ByVal hObject As Long) As Long
Private Declare Function CreateDC Lib "gdi32" Alias "CreateDCA" _
(ByVal lpDriverName As String, ByVal lpDeviceName As String, _
ByVal lpOutput As Long, ByVal lpInitData As Long) As Long
Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) _
As Long
Private Declare Function TextOut Lib "gdi32" Alias "TextOutA" _
(ByVal hdc As Long, ByVal x As Long, ByVal y As Long, _
ByVal lpString As String, ByVal nCount As Long) As Long ' or
Boolean
Private Declare Function StartDoc Lib "gdi32" Alias "StartDocA" _
(ByVal hdc As Long, lpdi As DOCINFO) As Long
Private Declare Function EndDoc Lib "gdi32" (ByVal hdc As Long) _
As Long
Private Declare Function StartPage Lib "gdi32" (ByVal hdc As Long)
_
As Long
Private Declare Function EndPage Lib "gdi32" (ByVal hdc As Long) _
As Long
Private Const DESIREDFONTSIZE = 12 ' Could use variable,
TextBox, etc.
Plaats een reactie op dit bericht
Ik ben bezig met een applicatie die 2 verticale teksten moet printen via de API. Nu was ik al heel blij dat ik dat op mijn HP6 aan de praat kreeg, ben niet zo'n API expert...
Het probleem is dat als ik het op een andere printer print (b.v Sharp AR 350 of HP5SI) de X van de verticale tekst anders is / er verkeerd wordt geprint.
API Masters please respond...
Bijvoorbaat dank,
Mike
Public Sub MakePrintApi()
' Combine API Calls with the Printer object
Dim OutString As String
Dim lf As LOGFONT
Dim result As Long
Dim hOldfont As Long
Dim hPrintDc As Long
Dim hFont As Long
hPrintDc = Printer.hdc
OutString = rtfData.Text
'DESIREDFONTSIZE = rtfData.Font.size
lf.lfFaceName = rtfData.Font.Name
lf.lfEscapement = 900
lf.lfHeight = (DESIREDFONTSIZE * -19.5) / Printer.TwipsPerPixelY
hFont = CreateFontIndirect(lf)
hOldfont = SelectObject(hPrintDc, hFont)
result = TextOut(hPrintDc, 155, 1600, OutString, Len(OutString))
result = TextOut(hPrintDc, 1880, 1600, OutString,
Len(OutString))
result = SelectObject(hPrintDc, hOldfont)
result = DeleteObject(hFont)
end sub
'Declaration section
Private Const LF_FACESIZE = 32
Private Type LOGFONT
lfHeight As Long
lfWidth As Long
lfEscapement As Long
lfOrientation As Long
lfWeight As Long
lfItalic As Byte
lfUnderline As Byte
lfStrikeOut As Byte
lfCharSet As Byte
lfOutPrecision As Byte
lfClipPrecision As Byte
lfQuality As Byte
lfPitchAndFamily As Byte
lfFaceName As String * LF_FACESIZE
End Type
Private Type DOCINFO
cbSize As Long
lpszDocName As String
lpszOutput As String
lpszDatatype As String
fwType As Long
End Type
Private Declare Function CreateFontIndirect Lib "gdi32" Alias _
"CreateFontIndirectA" (lpLogFont As LOGFONT) As Long
Private Declare Function SelectObject Lib "gdi32" _
(ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" _
(ByVal hObject As Long) As Long
Private Declare Function CreateDC Lib "gdi32" Alias "CreateDCA" _
(ByVal lpDriverName As String, ByVal lpDeviceName As String, _
ByVal lpOutput As Long, ByVal lpInitData As Long) As Long
Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) _
As Long
Private Declare Function TextOut Lib "gdi32" Alias "TextOutA" _
(ByVal hdc As Long, ByVal x As Long, ByVal y As Long, _
ByVal lpString As String, ByVal nCount As Long) As Long ' or
Boolean
Private Declare Function StartDoc Lib "gdi32" Alias "StartDocA" _
(ByVal hdc As Long, lpdi As DOCINFO) As Long
Private Declare Function EndDoc Lib "gdi32" (ByVal hdc As Long) _
As Long
Private Declare Function StartPage Lib "gdi32" (ByVal hdc As Long)
_
As Long
Private Declare Function EndPage Lib "gdi32" (ByVal hdc As Long) _
As Long
Private Const DESIREDFONTSIZE = 12 ' Could use variable,
TextBox, etc.
Plaats een reactie op dit bericht