关于DRAWTEXT
小弟最近想用DrawText输出文本,但不知道为什么就是不成功。代码如下:
Dim tRect As RECT
With tRect
.Left = 0
.Top = 0
.Right = 100
.Bottom = 100
End With
DrawText Me.hdc, "test", -1, tRect, DT_CENTER
望各位大神不吝赐教!
[解决办法]
在 Form_Load() 中调用?
前面加 Me.Show,必须可见后 API 绘图才能保留,否则显示后又被刷掉了。
[解决办法]
本帖最后由 bcrun 于 2013-06-18 16:38:45 编辑
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 Const DT_CENTER = &H1
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim tRect As RECT
With tRect
.Left = 0
.Top = 0
.Right = 100
.Bottom = 100
End With
DrawText Me.hdc, "test", -1, tRect, DT_CENTER
End Sub