- R -


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 graphical object. The rectangle is drawn with the color of the object's ForeColor property. It basically performs the same function as Visual Basic's Line command when used with the B parameter. However, my own tests have shown that the Rectangle API function is slightly faster than the Visual Basic equivalent! So, if you are going to do a lot of graphics-intensive programming, use this code. If not, you should probably use Line. This function returns an error code you can safely disregard.
hdcThe device context of the object.
X1The x coordinate of the rectangle's upper-left corner.
Y1The y coordinate of the rectangle's upper-left corner.
X2The x coordinate of the rectangle's lower-right corner.
Y2The y coordinate of the rectangle's lower-right corner.
Example:
  Draw a green rectangle
  Picture1.ForeColor = RGB(0, 255, 0) 'green
  x = Rectangle(Picture1.hdc, 25, 25, 100, 50)


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


ReleaseDC Function

Declare Function ReleaseDC Lib "user32.dll" (ByVal hWnd As Long, ByVal hdc As Long) As Long

ReleaseDC breaks the association between an object and a variable holding its device context (DC). 99% of the time they will have been linked with GetDC. You should break the association when you are done using the device context of an object in order to free memory and system resources. It is save to ignore the return value.
hWndThe handle of the object to break the association with.
hdcThe variable holding the object's device context.
Example:
  x = ReleaseDC(desktophWnd, desktophdc)

Related Call: GetDC
Category: Devices
Back to the index.


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 graphical object. It is drawn in the object's ForeColor property. The first two (x,y) coordinate pairs in the parameter list are the upper-left and lower-right corners of a square-cornered rectangle the same dimensions as the one to be drawn. The last pair are the height and width of the ellipse used to make the rounded corners. Each corner is drawn as a corresponding "corner" of an ellipse of height 2*Y3 and width 2*X3. That is, X3 and Y3 are the width and height of the rounded corner. You can safely ignore the value returned.
hdcThe device context of the graphical object to draw on.
X1The x coordinate of the upper-left corner of the corresponding square-edged rectangle.
Y1The y coordinate of the upper-left corner of the corresponding square-edged rectangle.
X2The x coordinate of the lower-right corner of the corresponding square-edged rectangle.
Y2The y coordinate of the lower-right corner of the corresponding square-edged rectangle.
X3The width of each elliptical rounded corner.
Y3The height of each elliptical rounded corner.
Example:
  'Draw a rounded rectangle with rounded corners 10 pixels wide and 5 high
  'The rectangle stretches from (10,10) to (150,100).
  'Draw this on Form1
  Form1.Cls 'Clear drawings on the form
  x = RoundRect(Form1.hDC, 10, 10, 150, 100, 10, 5)


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


Home
Paul Kuliniewicz
E-mail: Borg953@aol.com
All material presented on these pages is Copyright © Paul Kuliniewicz, except for other copyrighted material.
http://members.aol.com/Borg953/api/r.html