为什么FORM 或 PICTUREBOX 的 AutoRedraw属性设为TRUE,就无法用API显示文本?

BadCatw 2001-11-08 03:38:44
如将 PICTUREBOX的AUTOREDRAW设为TRUE,用:
DrawText 等API函数无法在图片框上显示文本,请问如何解决?
...全文
95 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
BadCatw 2001-11-11
  • 打赏
  • 举报
回复
to uguess(uguess) :

谢谢,我回去试试。
uguess 2001-11-08
  • 打赏
  • 举报
回复

谁说显示不出来?试试我下面的例子,记着把FORM的AutoRedraw属性设为TRUE!

Option Explicit

Const DC_ACTIVE = &H1
Const DC_ICON = &H4
Const DC_TEXT = &H8
Const BDR_SUNKENOUTER = &H2
Const BDR_RAISEDINNER = &H4
Const EDGE_ETCHED = (BDR_SUNKENOUTER Or BDR_RAISEDINNER)
Const BF_BOTTOM = &H8
Const BF_LEFT = &H1
Const BF_RIGHT = &H4
Const BF_TOP = &H2
Const BF_RECT = (BF_LEFT Or BF_TOP Or BF_RIGHT Or BF_BOTTOM)
Const DFC_BUTTON = 4
Const DFC_POPUPMENU = 5 'Only Win98/2000 !!
Const DFCS_BUTTON3STATE = &H10
Const DT_CENTER = &H1
Const DC_GRADIENT = &H20 'Only Win98/2000 !!
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function DrawCaption Lib "user32" (ByVal hWnd As Long, ByVal hdc As Long, pcRect As RECT, ByVal un As Long) As Long
Private Declare Function DrawEdge Lib "user32" (ByVal hdc As Long, qrc As RECT, ByVal edge As Long, ByVal grfFlags As Long) As Long
Private Declare Function DrawFocusRect Lib "user32" (ByVal hdc As Long, lpRect As RECT) As Long
Private Declare Function DrawFrameControl Lib "user32" (ByVal hdc As Long, lpRect As RECT, ByVal un1 As Long, ByVal un2 As Long) As Long
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 Declare Function SetRect Lib "user32" (lpRect As RECT, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function OffsetRect Lib "user32" (lpRect As RECT, ByVal x As Long, ByVal y As Long) As Long

Private Sub Form_Load()
'KPD-Team 1999
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@Allapi.net
Dim R As RECT
'Clear the form
Me.Cls
'API uses pixels
Me.ScaleMode = vbPixels
'Set the rectangle's values
SetRect R, 0, 0, Me.ScaleWidth, 20
'Draw a caption on the form
DrawCaption Me.hWnd, Me.hdc, R, DC_ACTIVE Or DC_ICON Or DC_TEXT Or DC_GRADIENT
'Move the recatangle
OffsetRect R, 0, 22
'Draw an edge on our window
DrawEdge Me.hdc, R, EDGE_ETCHED, BF_RECT
OffsetRect R, 0, 22
'Draw a focus rectangle on our window
DrawFocusRect Me.hdc, R
OffsetRect R, 0, 22
'Draw a frame control on our window
DrawFrameControl Me.hdc, R, DFC_BUTTON, DFCS_BUTTON3STATE
OffsetRect R, 0, 22
'draw some text on our form
DrawText Me.hdc, "Hello World !", Len("Hello World !"), R, DT_CENTER
End Sub

Jneu 2001-11-08
  • 打赏
  • 举报
回复
使 PictureBox 控件的自动重绘有效。图形和文本输出到屏幕,并存储在内存的图象中。该对象不接受绘制事件,必要时,用存储在内存中的图象进行重绘。
Amoon 2001-11-08
  • 打赏
  • 举报
回复
没办法

1,486

社区成员

发帖
与我相关
我的任务
社区描述
VB API
社区管理员
  • API
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧