Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function ScreenToClient Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Private Sub Command2_Click()
Dim ret As RECT
Dim ip As POINTAPI
GetWindowRect Command1.hwnd, ret '得到command1的位置
ip.x = ret.Left
ip.y = ret.Top
ScreenToClient Me.hwnd, ip '转换,单位为象素
Debug.Print ip.x
Debug.Print ip.y
End Sub