在用textout的时候 textout picture1.hdc, x,y,text1.text,len(text1.text) 在输入英文字时没错 当输入汉字时picture1只显示一半的汉字,要是用2*len(text1.text) 输入汉字没问题 但输入英文的时候 会随机的后面输入奇怪的东西,怎么解决可以同时输入汉字和英文字呀 
  怎么才能使picturebox中的图片和picture一样大,当其像素是不变的? 谢谢

解决方案 »

  1.   

    lenB()这个函数可以吗?我无法测试。
      

  2.   

    textout picture1.hdc, x,y,text1.text,len(StrConv(text1.text),vbFromUnicode)
      

  3.   

    发错了,是这个
    textout picture1.hdc, x,y,text1.text,lenB(StrConv(text1.text),vbFromUnicode)
      

  4.   

    那就试试看这个API吧:
    DrawText说明:
    Declare Function DrawText Lib "user32" Alias "DrawTextA" (ByVal hdc As Long, ByVal lpStr As String, ByVal nCount As Long, lpRect As RECT, ByVal wFormat As Long) As Long写了个简单的例子,楼主用一下:
    Option Explicit
    Private Declare Function DrawText Lib "user32" Alias "DrawTextA" (ByVal hdc As Long, ByVal lpStr As String, ByVal nCount As Long, lpRect As Rect, ByVal wFormat As Long) As Long
    Private Type Rect
       l As Long
       t As Long
       r As Long
       b As Long
    End Type
     Const COLOR_CAPTIONTEXT = 9
     Const DT_CENTER = &H1      'centre left to right
     Const DT_VCENTER = &H4     'centre top to bottom
     Const DT_NOCLIP = &H100    'fast draw
     Const DT_SINGLELINE = &H20 'single line only
     Const DT_FLAGS = DT_SINGLELINE Or DT_CENTER Or DT_VCENTER Or DT_NOCLIPPrivate Sub Command1_Click()
    Dim rec As Rect
    rec.l = 10
    rec.t = 10
    rec.r = 100
    rec.b = 20
    'TextOut Picture1.hdc, 0, 0, "iudshfsid", 10
    DrawText Picture1.hdc, "iuhfoisuffhswfiew", -1, rec, DT_FLAGS
    End Sub使用这个API,将第3个参数设为-1就可以输出整个字符串而不管字符串的字符数
      

  5.   

    结束贴
    这种是对的textout  picture1.hdc,  x,y,text1.text,lenB(StrConv(text1.text,vbFromUnicode) )
      

  6.   

    没有试过WallesCai(沧海明月一度,西风残阳无悔.) 的东西 不过 依然谢谢你