.paren 方法只能找到父窗体,找不到控件所在的上层 frame!!!! 卡住了!
只要用代码实现,识别出Command1这个控件的 上一级分组容器名称是 frame2就行了。
[此贴子已经被作者于2021-12-12 14:32编辑过]
程序代码:Dim x As Long, y As Long, obj As Object
x = Command1.Left '自己的坐标
y = Command1.Top
Set obj = Command1.Container '上一层容器
Do
If obj Is Me Then Exit Do '如果为放控件的窗体本身退出循环
x = x + obj.Left
y = y + obj.Top
Set obj = obj.Container '继续取上一层容器
Loop
'If Me.MDIChild Then '如果是mdi子窗体再加上窗口坐标
' x = x + Me.Top
' y = y + Me.Left
'End If
Debug.Print x, y
Debug.Print Command1.Left, Command1.Top
Debug.Print Frame1.Left, Frame1.Top
Debug.Print Picture1.Left, Picture1.Top
