'获得整个窗口的范围矩形 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 TypePrivate Sub Command1_Click() Dim myRect As RECT GetWindowRect From1.Picture1.hwnd, myRect Me.Print myRect.Top Me.Print myRect.Left Me.Print myRect.Bottom Me.Print myRect.Right End Sub
Private Sub Command1_Click() Dim rc As RECT GetWindowRect Picture2.hWnd, rc MapWindowPoints 0, Me.hWnd, rc, 2 Debug.Print rc.Left, rc.Top, rc.Right, rc.bottom End Sub
'获得整个窗口的范围矩形
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 TypePrivate Sub Command1_Click()
Dim myRect As RECT GetWindowRect From1.Picture1.hwnd, myRect
Me.Print myRect.Top
Me.Print myRect.Left
Me.Print myRect.Bottom
Me.Print myRect.Right
End Sub
Dim rc As RECT
GetWindowRect Picture2.hWnd, rc
MapWindowPoints 0, Me.hWnd, rc, 2
Debug.Print rc.Left, rc.Top, rc.Right, rc.bottom
End Sub