Export (0) Print
Expand All

GetWindowRgn function

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

Syntax


int GetWindowRgn(
  _In_  HWND hWnd,
  _In_  HRGN hRgn
);

Parameters

hWnd [in]

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

hRgn [in]

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 codeDescription
NULLREGION

The region is empty.

SIMPLEREGION

The region is a single rectangle.

COMPLEXREGION

The region is more than one rectangle.

ERROR

The specified window does not have a region, or an error occurred while attempting to return the region.

 

Remarks

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.

Examples

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 */


Requirements

Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Winuser.h (include Windows.h)

Library

User32.lib

DLL

User32.dll

See also

Painting and Drawing Overview
Painting and Drawing Functions
SetWindowRgn

 

 

Community Additions

ADD
Show:
© 2014 Microsoft