关于textout输出到打印机实现输出文本的定位,
Printer.Print " "
hPrintDc = Printer.hdc
OutString = "案卷题名"
lf.lfEscapement = 900
lf.lfHeight = (DESIREDFONTSIZE * 30) / Printer.TwipsPerPixelY
lf.lfCharSet = 1
lf.lfFaceName = "华文中宋" + Chr(0)
hFont = CreateFontIndirect(lf)
hOldfont = SelectObject(hPrintDc, hFont)
y1 = 1200 + i * 576 * 2.4 + 150 * i
result = TextOut(hPrintDc, 3400, y1, OutString, LenB(StrConv(OutString, vbFromUnicode))) '这里我想把字符打印在指定的位置 ,但是不能改变位置
result = SelectObject(hPrintDc, hOldfont)
result = DeleteObject(hFont)
Printer.Print " "
hPrintDc = Printer.hdc
OutString = "案卷题名"
lf.lfEscapement = 900
lf.lfHeight = (DESIREDFONTSIZE * 30) / Printer.TwipsPerPixelY
lf.lfCharSet = 1
lf.lfFaceName = "华文中宋" + Chr(0)
hFont = CreateFontIndirect(lf)
hOldfont = SelectObject(hPrintDc, hFont)
y1 = 1200 + i * 576 * 2.4 + 150 * i
result = TextOut(hPrintDc, 3400, y1, OutString, LenB(StrConv(OutString, vbFromUnicode))) '这里我想把字符打印在指定的位置 ,但是不能改变位置
result = SelectObject(hPrintDc, hOldfont)
result = DeleteObject(hFont)
result = TextOut(hPrintDc, 3400, y1, OutString, LenB(StrConv(OutString, vbFromUnicode))) '这里我想把字符打印在指定的位置 ,但是不能改变位置
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(1 To 32) As Byte
End Type
Private Const LF_FACESIZE = 32
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function CreateFontIndirect Lib "gdi32" Alias "CreateFontIndirectA" (lpLogFont As LOGFONT) 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
Private Declare Function SelectObject Lib "gdi32" (ByVal hDc As Long, ByVal hObject As Long) As LongPrivate Sub Command1_Click()
Dim lF As LOGFONT
With lF
.lfEscapement = 450 '顺时针旋转45度(角度*10)
.lfWidth = 100 '字体宽度
.lfHeight = 100 '字体高度
.lfCharSet = GB2312_CHARSET '打印汉字
End With
Dim Ft As Long
Dim tS As String
tS = "汉字"
Ft = CreateFontIndirect(lF)
SelectObject Picture1.hDc, Ft
TextOut Picture1.hDc, 200, 300, tS, LenB(tS)
DeleteObject Ft
End Sub