CreateRectRgn Function

Declare Function CreateRectRgn Lib "gdi32.dll" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long

Platforms: Win 32s, Win 95/98, Win NT

CreateRectRgn creates a rectangularly-shaped region and provides a handle to it. The rectangle defining the region is specified by passing its upper-left and lower-right corners to the function. Note that the bottom and right edges of the rectangle are not considered to be part of the region. The function returns a handle to the newly created region if successful, or 0 if an error occured.

X1
The x-coordinate of the upper-left corner of the rectangle.
Y1
The y-coordinate of the upper-left corner of the rectangle.
X2
The x-coordinate of the lower-right corner of the rectangle.
Y2
The y-coordinate of the lower-right corner of the rectangle.

Example:

' Invert the pixels within a rectangular region on window Form1.  The region
' has corners (20,30)-(150,110).
Dim hrgn As Long  ' handle to the rectangular region
Dim retval As Long  ' return value

' Create the rectangular region and get a handle to it.
hrgn = CreateRectRgn(20, 30, 150, 110)  ' has corners (20,30)-(150,110)
' Invert the pixels on Form1 within this region.
retval = InvertRgn(Form1.hDC, hrgn)
' Delete the region to free up resources.
retval = DeleteObject(hrgn)

See Also: CreateRectRgnIndirect, CreateRoundRectRgn
Category: Regions

Go back to the alphabetical Function listing.
Go back to the Reference section index.


This page is copyright © 2000 Paul Kuliniewicz. Copyright Information.
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/c/createrectrgn.html