-
How can I recieve a windows Width, Height, Top, Left, by just knowing it's caption or hWnd ?
And how can I resize a window to any Height, Width, Top, Left, that I want, by just knowing the windows hWnd or Caption ?
The Windows is not part of my program, like, how do I resize Windows Explorer, from within my program, and know it's current size ?
Please help me.
-
You can try something like this:
Code:
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Sub Form_Load()
Dim lHwnd As Long
Dim rc As RECT
Dim strMsg As String
lHwnd = FindWindowEx(0, 0, vbNullString, "CaptionOfProgram")
Call GetWindowRect(lHwnd, rc)
strMsg = "Height: " & rc.Bottom - rc.Top & vbCrLf
strMsg = strMsg & "Width: " & rc.Right - rc.Left & vbCrLf
strMsg = strMsg & "Top: " & rc.Top & vbCrLf
strMsg = strMsg & "Left: " & rc.Left
End Sub
Just substitute CaptionOfProgram with the appropriate caption.