说三道四技术文摘-感悟人生的经典句子
说三道四 > 文档快照

VB取得控件绝对Top值

HTML文档下载 WORD文档下载 PDF文档下载
VB取得控件绝对Top值
Public Function AbsoluteTop(ctlContl As Control) As Single
Dim wrkContl As Control
Dim wrkTopPos As Single

On Error GoTo AbsoluteTopError
'初始
Set wrkContl = ctlContl
wrkTopPos = 0
'循环
Do
If (wrkContl.Container.Name = ctlContl.Parent.Name) Then Exit Do
wrkTopPos = wrkTopPos + wrkContl.Top ' 计算位置
Set wrkContl = wrkContl.Container ' 下个控件
Loop

AbsoluteTop = wrkTopPos + ctlContl.Parent.Top
Exit Function

AbsoluteTopError:
AbsoluteTop = ctlContl.Top + ctlContl.Parent.Top
Exit Function
End Function

备案号:鲁ICP备13029499号-2 说三道四 www.s3d4.cn 说三道四技术文摘