请问如何得到指定窗体的坐标啊

来源:百度知道 编辑:UC知道 时间:2024/05/17 22:30:25
请问如何得到一个指定窗体的的坐标,如记事本的的坐标?我用的是VB6.0

谢谢啊

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function GetClientRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Dim lhwnd As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long

End Type

Private Sub Command1_Click()
Dim ret As RECT
GetWindowRect lhwnd, ret
MsgBox "窗体的X座标是:" & ret.Left & " Y座标是:" & ret.Top & " 宽度是:" & ret.Right & " 高度是:" & ret.Bottom
End Sub

Private Sub Form_Load()
lhwnd = FindWindow(vbNullString, "计算器")
Debug.Print lhwnd
End Sub

打开 附件中的 计算器

主要用到
GetWin