Unicode printing on a PRINTER in VB6

2020-05-09 06:07发布

I'm trying to print a Unicode (Chinese) string on a printer (well, actually PDFCreator) but all I get is a VERTICAL print of the characters.

I use the TextOutW function imported from gdi32.dll:

TextOutW dest.hDC, x, y, StrConv(szText, vbUnicode), Len(szText)

And if I try to print "0.12" (if I print Chinese characters, I get the same result anyway), I get

0
.
1
2

If I use the dest.Print function, I am not able to print Unicode.

Anyway, TextOutW works WONDERFULLY on the screen.

Can anyone help me solve this?

1条回答
姐就是有狂的资本
2楼-- · 2020-05-09 06:56

What is the definition of szText? Is it a VB6 string? In which case try

Private Declare Function  Lib "gdi32" Alias "TextOutW" ( _
  ByVal hdc As Long, ByVal x As Long, ByVal y As Long, _
  ByVal lpStringU As Long, ByVal nCount As Long) As Long  

TextOutW dest.hDC, x, y, StrPtr(szText), Len(szText) 

Note

  • StrPtr not StrConv(... , vbUnicode)
  • Declare for TextOutW has ByVal lpStringU As Long
查看更多
登录 后发表回答