Friday, July 03, 2015
    Search Web Link
Search Software
API Home » Window » GetWindowRect


Category: Window
Hits: 15853 Rating: GetWindowRect has been rated 2.05 by  1255 users (2.05) votes 1255
Rate: 1-star  2-stars  3-stars  4-stars  5-stars
E-mail this API to friend E-mail this Code to a friend  save Bookmark this VB API Function
API Explanation
GetWindowRect reads the size and position of a window. This information is put into the variable passed as lpRect. The rectangle receives the coordinates of the upper-left and lower-right corners of the window. If the window is past one of the edges of the screen, the values will reflect that (for example, if the left edge of a window is off the screen, the rectangle's .Left property will be negative). The function returns 0 if an error occured, or 1 if successful.

Parameter Information
Declare Function GetWindowRect Lib "user32.dll" _
(ByVal hwnd As Long, lpRect As RECT) As Long

The handle of the window to read the position and width of.
Variable that receives the coordinates of the upper-left and lower-right corners of the window.

' Display the width and height of window Form1
' Width and height can be calculated from the coordinates returned in the rectangle.
Dim r As RECT ' receives window rectangle
Dim retval As Long ' return value

retval = GetWindowRect(Form1.hWnd, r) ' set r equal to Form1's rectangle
Debug.Print "Width ="; r.Right - r.Left
Debug.Print "Height ="; r.Bottom - r.Top

Copyright © 2000 - 2013 Ex-designz. All rights reserved. Website Developed By Dexter Zafra of
Link to us | Advertisement | Contact us | Privacy Policy | Terms of use | Accessibility