关于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)

解决方案 »

  1.   

    直接操作Printer对象的CurrentX、CurrentY、Font属性不好吗?
      

  2.   

    我要打印旋转90度的字体(包括中音文) 请问怎么样
    result   =   TextOut(hPrintDc,   3400,   y1,   OutString,   LenB(StrConv(OutString,   vbFromUnicode)))       '这里我想把字符打印在指定的位置 ,但是不能改变位置 
      

  3.   

    在指定位置旋转输入文字,试了一下没问题啊,不知道你说的“不能改变位置”是什么意思。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(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