API函数申明和类型定义就不写了,以下是我的调用代码,但是在矩形中就是写不出字,
Private Sub Command1_Click()
Dim DrawRect As RECT
Dim FillName As String
Dim DrawPoint As DRAWTEXTPARAMS
Dim result As Long
DrawRect.Bottom = 70
DrawRect.Left = 80
DrawRect.Right = 200
DrawRect.Top = 10 Call FrameRect(Picture1.hdc, DrawRect, lPen)
FillName = "How are you!" DrawPoint.cbSize = 5
DrawPoint.iLeftMargin = 1
DrawPoint.iRightMargin = 1
DrawPoint.iTabLength = 0
DrawPoint.uiLengthDrawn = Len(FillName) Call DrawTextEx(Picture1.hdc, FillName, Len(FillName), DrawRect, DT_CENTER, DrawPoint)
End Sub
Private Sub Command1_Click()
Dim DrawRect As RECT
Dim FillName As String
Dim DrawPoint As DRAWTEXTPARAMS
Dim result As Long
DrawRect.Bottom = 70
DrawRect.Left = 80
DrawRect.Right = 200
DrawRect.Top = 10 Call FrameRect(Picture1.hdc, DrawRect, lPen)
FillName = "How are you!" DrawPoint.cbSize = 5
DrawPoint.iLeftMargin = 1
DrawPoint.iRightMargin = 1
DrawPoint.iTabLength = 0
DrawPoint.uiLengthDrawn = Len(FillName) Call DrawTextEx(Picture1.hdc, FillName, Len(FillName), DrawRect, DT_CENTER, DrawPoint)
End Sub
解决方案 »
- MBP图像压缩技术,下面有段VB程序,小弟实在看不懂是怎么压缩的。求各位大哥大姐帮帮忙
- 求一段VB程序的含义(3),delphi程序员的HELP
- 请教:文本框滚动问题
- 用 INTERNET TRANSFER 控件操作 FTP 的两个问题
- 我就干出血怎地!100分
- 版主请帮帮忙,其他同行的答复都不行,在线等待
- [求助]想实现一个“批量删除若干excel文件的某1个单元格里的值”的功能
- 编写函数和方法的问题
- 一个小问题。sql语句的问题!快进来拿分!看谁快!!!很紧急!!!80分!!
- lou_df(ldf) 请问还要安装一套什么程序 ,谢谢
- [原创]vb写的SQL查询分析器1.0版本
- 有江苏盱眙的程序员吗?
应该是DrawPoint.cbSize = Len(DrawPoint)另,在测试中,我还去掉了Call FrameRect(Picture1.hdc, DrawRect, lPen)这句,
能正常显示,
改后的代码如下Private Sub Command1_Click()
Dim DrawRect As RECT
Dim FillName As String
Dim DrawPoint As DRAWTEXTPARAMS
Dim result As Long
DrawRect.Bottom = 70
DrawRect.Left = 80
DrawRect.Right = 200
DrawRect.Top = 10 'Call FrameRect(Picture1.hDC, DrawRect, lPen)
FillName = "How are you!"
DrawPoint.cbSize = Len(DrawPoint)
'DrawPoint.cbSize = 5
DrawPoint.iLeftMargin = 1
DrawPoint.iRightMargin = 1
DrawPoint.iTabLength = 0
DrawPoint.uiLengthDrawn = Len(FillName) Call DrawTextEx(Picture1.hDC, FillName, Len(FillName), DrawRect, DT_CENTER, DrawPoint)
End Sub
cbSize是DRAWTEXTPARAMS结构在内存中所占的size,楼主可能把结构size和结构成员数混淆了。在VB中该结构的每个成员为Long类型,Long在内存中占4个字节,4*5=20,用len(变量名)可以得到结构所占内存size。