# Rectangle Function

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

Rectangle draws a rectangular-shaped box on a graphics-capable device. The rectangle is drawn using the color of the object's .ForeColor property. The function returns 0 if an error occured, or a non-zero value if successful.

hdc
  The device context of the object to draw on.
X1
  The x coordinate of the rectangle's upper-left corner.
Y1
  The y coordinate of the rectangle's upper-left corner.
X2
  The x coordinate of the rectangle's lower-right corner.
Y2
  The y coordinate of the rectangle's lower-right corner.

Example:

    ' Draw a green rectangle on Picture1 from (25,25) to (100,50)
    Picture1.ForeColor = RGB(0, 255, 0)  ' green
    x = Rectangle(Picture1.hdc, 25, 25, 100, 50)

Related Call: RoundRect
Category: Graphics
Back to the index.