Click to Rate and Give Feedback
MSDN
MSDN Library
User Interface
Windowing
Windows
Windows Reference
Functions
 GetClientRect Function
GetClientRect Function

The GetClientRect function retrieves the coordinates of a window's client area. The client coordinates specify the upper-left and lower-right corners of the client area. Because client coordinates are relative to the upper-left corner of a window's client area, the coordinates of the upper-left corner are (0,0).

Syntax

BOOL GetClientRect(      
    HWND hWnd,     LPRECT lpRect );

Parameters

hWnd
[in] Handle to the window whose client coordinates are to be retrieved.
lpRect
[out] Pointer to a RECT structure that receives the client coordinates. The left and top members are zero. The right and bottom members contain the width and height of the window.

Return Value

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

In conformance with conventions for the RECT structure, the bottom-right coordinates of the returned rectangle are exclusive. In other words, the pixel at (right, bottom) lies immediately outside the rectangle.

Example

For example, see Creating, Enumerating, and Sizing Child Windows.

Function Information

Minimum DLL Versionuser32.dll
HeaderDeclared in Winuser.h, include Windows.h
Import libraryUser32.lib
Minimum operating systems Windows 95, Windows NT 3.1
UnicodeImplemented as Unicode version.

See Also

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Opengl and using GetClientRect      Xilliah   |   Edit   |   Show History

It is not strange to set the opengl viewport to the width and height of a window's client area. Opengl is generally painted upon the main window of an application.

However you might change your mind and try to draw upon a child window. Specifically, one that has WM_CHILD set in dwStyles. This can generate issued as such windows don't seem to be able to return their client area's width and height via the GetClientRect function. If you use these values, the viewport will collapse, and only the clearing color will be visible.

Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker