GetWindowRgn function (winuser.h)

The GetWindowRgn function obtains a copy of the window region of a window. The window region of a window is set by calling the SetWindowRgn function. The window region determines the area within the window where the system permits drawing. The system does not display any portion of a window that lies outside of the window region


int GetWindowRgn(
  HWND hWnd,
  HRGN hRgn



Handle to the window whose window region is to be obtained.


Handle to the region which will be modified to represent the window region.

Return value

The return value specifies the type of the region that the function obtains. It can be one of the following values.

Return code Description
The region is empty.
The region is a single rectangle.
The region is more than one rectangle.
The specified window does not have a region, or an error occurred while attempting to return the region.


The coordinates of a window's window region are relative to the upper-left corner of the window, not the client area of the window.

To set the window region of a window, call the SetWindowRgn function.


The following code shows how you pass in the handle of an existing region.

HRGN hrgn = CreateRectRgn(0,0,0,0);
int regionType = GetWindowRgn(hwnd, hrgn);
if (regionType != ERROR) 
/* hrgn contains window region */ 
DeleteObject(hrgn); /* finished with region */


Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header winuser.h (include Windows.h)
Library User32.lib
DLL User32.dll
API set ext-ms-win-ntuser-draw-l1-1-2 (introduced in Windows 10, version 10.0.10240)

See also

Painting and Drawing Functions

Painting and Drawing Overview