module1.base 模块
Option ExplicitDeclare 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
Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Declare Function SetRectEmpty Lib "user32" (lpRect As RECT) As Long
Declare Function SetTextCharacterExtra Lib "gdi32" (ByVal hdc As Long, ByVal nCharExtra As Long) As Long
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
Declare Function GetTextCharacterExtra Lib "gdi32" (ByVal hdc As Long) As Long
Declare Function GetTextExtentPoint32 Lib "gdi32" Alias "GetTextExtentPoint32A" (ByVal hdc As Long, ByVal lpsz As String, ByVal cbString As Long, lpSize As POINTAPI) As LongPublic Const DT_TOP = &H0
Public Const DT_VCENTER = &H4
Public Const DT_BOTTOM = &H8
Public Const DT_LEFT = &H0
Public Const DT_CENTER = &H1
Public Const DT_RIGHT = &H2
Public Const DT_SINGLELINE = &H20
Public Const DT_CALCRECT = &H400
Public Const DT_WORDBREAK = &H10Public Type POINTAPI
x As Long
y As Long
End Type
Public Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
str = "123566"
LngInter = 3
rc = SetRect(R, Label1.Left / Screen.TwipsPerPixelX, Label1.Top / Screen.TwipsPerPixelY, _
(Label1.Left + Label1.Width) / Screen.TwipsPerPixelX, _
(Label1.Top + Label1.Height) / Screen.TwipsPerPixelY)
rc = SetTextCharacterExtra(Picture1.hdc, LngInter)
rc = DrawText(Picture1.hdc, str, -1, R, DT_RIGHT)
End Sub此代码在windows 2000下运行时没有问题,但是为什么在win xp 下会剪掉右边一部分文本(右对齐时),谁能解决这个难题?高手赶紧帮帮忙!很急的!^_^
随便说一下,谁能告诉我win xp 和win 2000的函数区别,是不是不兼容函数?
Option ExplicitDeclare 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
Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Declare Function SetRectEmpty Lib "user32" (lpRect As RECT) As Long
Declare Function SetTextCharacterExtra Lib "gdi32" (ByVal hdc As Long, ByVal nCharExtra As Long) As Long
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
Declare Function GetTextCharacterExtra Lib "gdi32" (ByVal hdc As Long) As Long
Declare Function GetTextExtentPoint32 Lib "gdi32" Alias "GetTextExtentPoint32A" (ByVal hdc As Long, ByVal lpsz As String, ByVal cbString As Long, lpSize As POINTAPI) As LongPublic Const DT_TOP = &H0
Public Const DT_VCENTER = &H4
Public Const DT_BOTTOM = &H8
Public Const DT_LEFT = &H0
Public Const DT_CENTER = &H1
Public Const DT_RIGHT = &H2
Public Const DT_SINGLELINE = &H20
Public Const DT_CALCRECT = &H400
Public Const DT_WORDBREAK = &H10Public Type POINTAPI
x As Long
y As Long
End Type
Public Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
str = "123566"
LngInter = 3
rc = SetRect(R, Label1.Left / Screen.TwipsPerPixelX, Label1.Top / Screen.TwipsPerPixelY, _
(Label1.Left + Label1.Width) / Screen.TwipsPerPixelX, _
(Label1.Top + Label1.Height) / Screen.TwipsPerPixelY)
rc = SetTextCharacterExtra(Picture1.hdc, LngInter)
rc = DrawText(Picture1.hdc, str, -1, R, DT_RIGHT)
End Sub此代码在windows 2000下运行时没有问题,但是为什么在win xp 下会剪掉右边一部分文本(右对齐时),谁能解决这个难题?高手赶紧帮帮忙!很急的!^_^
随便说一下,谁能告诉我win xp 和win 2000的函数区别,是不是不兼容函数?
并且label1要放在空间picture1上面Private Sub Form_Load()
Picture1.AutoRedraw = False
Picture1.Appearance = 0
Label1.Appearance = 0
Label1.BorderStyle = 1End Sub
我会直接放弃DrawText,自己计算坐标、用TextOut一个一个地绘制文字
因为再怎么设置参数,也会留下隐患(比如有新的操作系统出来)至于WinXP与Win2000的区别在于:增加了主题风格函数、GDI+,集成了更高的DirectX版本,为ListView添加了许多新功能