VB6获取控件客户区可用尺寸类

评价:
0
(0用户)

Option Explicit
Private Declare Function GetClientRect Lib “user32” (ByVal hWnd As Long, lpRect As RECT) As Long
Private Type RECT
X1 As Long
Y1 As Long
X2 As Long
Y2 As Long
End Type
Private lpR As RECT
Private objCtrl As Object
Private smcScaleTo As ScaleModeConstants

Public Function Attach(ObjectCtrl As Object)
Set objCtrl = ObjectCtrl
smcScaleTo = objCtrl.ScaleMode
GetClientRect objCtrl.hWnd, lpR

End Function
Property Get LeftClient() As Single
LeftClient = objCtrl.ScaleX(lpR.X1, vbPixels, smcScaleTo)
End Property
Property Get TopClient() As Single
TopClient = objCtrl.ScaleY(lpR.Y1, vbPixels, smcScaleTo)
End Property
Property Get WidthClient() As Single
WidthClient = objCtrl.ScaleX(lpR.X2 – lpR.X1, vbPixels, smcScaleTo)
End Property
Property Get HeightClient() As Single
HeightClient = objCtrl.ScaleY(lpR.Y2 – lpR.Y1, vbPixels, smcScaleTo)
End Property

Private Sub Class_Initialize()
Set objCtrl = Nothing

End Sub

本文为原创文章,转载请注明出处!

注册并通过认证的用户才可以进行评价!

admin:系统自动奖励,+10,  

发表评论