PathToRegion function (wingdi.h)

The PathToRegion function creates a region from the path that is selected into the specified device context. The resulting region uses device coordinates.


HRGN PathToRegion(
  [in] HDC hdc


[in] hdc

Handle to a device context that contains a closed path.

Return value

If the function succeeds, the return value identifies a valid region.

If the function fails, the return value is zero.


When you no longer need the HRGN object call the DeleteObject function to delete it.

The device context identified by the hdc parameter must contain a closed path.

After PathToRegion converts a path into a region, the system discards the closed path from the specified device context.


Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header wingdi.h (include Windows.h)
Library Gdi32.lib
DLL Gdi32.dll