Command1.Parent.Caption = "测试" '所在窗体
Command1.Container.Caption = "测试2" '所在容器,直接在窗体上时,窗口为容器
-------测试代码--------
程序代码:
Command1.Container.Caption = "测试2" '所在容器,直接在窗体上时,窗口为容器
-------测试代码--------

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

授人于鱼,不如授人于渔
早已停用QQ了