Private Declare Function DrawStateString Lib "user32" Alias "DrawStateA" (ByVal hdc As Long, _
ByVal hBrush As Long, _
ByVal lpDrawStateProc As Long, _
ByVal lpString As String, _
ByVal cbStringLen As Long, _
ByVal X As Long, _
ByVal Y As Long, _
ByVal cx As Long, _
ByVal cy As Long, _
ByVal fuFlags As Long) As Long
DrawStateString Picturt.hdc ,0,0 ,"你好!",LenB(StrConv("你好!",vbFromUnicode)), 10,10, 100,100,2 or Normal
最后的一个参数设置效果
Normal = 0
DISABLED = &H20&
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
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 Sub Command1_Click()
Dim strTmp As String, nCount As Integer, m_Rect As RECT
Dim i As Long
strTmp = Text1.Text
For i = 1 To Len(strTmp)
If VBA.Asc(Mid(strTmp, i, 1)) < 0 Then
nCount = nCount + 2
Else
nCount = nCount + 1
End If
Next
'以下以象数为单位
m_Rect.Left = 10
m_Rect.Right = 200
m_Rect.Top = 10
m_Rect.Bottom = 200
DrawText Picture1.hdc, strTmp, nCount, m_Rect, DT_LEFT Or DT_WORDBREAK