# RoundRect Function

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

RoundRect draws a rectangle with rounded corners on a graphics-capable device. It is drawn in the color of the object's .ForeColor property. The first two (x,y) coordinate pairs specified are the upper-left and lower-right corners a square-cornered rectangle. The third pair specifies the width and height of the rounded corner to use. 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 upper-left corner of the corresponding square-edged rectangle.
Y1
  The y coordinate of the upper-left corner of the corresponding square-edged rectangle.
X2
  The x coordinate of the lower-right corner of the corresponding square-edged rectangle.
Y2
  The y coordinate of the lower-right corner of the corresponding square-edged rectangle.
X3
  The width of the rounded corner.
Y3
  The height of the rounded corner.

Example:

    ' Draw a rounded rectangle with rounded corners 10 wide and 5 high
    ' The rectangle goes from (10,10)-(150,150) and is blue
    Picture1.ForeColor = RGB(0, 0, 255)  ' blue
    x = RoundRect(Picture1.hDC, 10, 10, 150, 150, 10, 5)

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