FrameRect Function

Declare Function FrameRect Lib "user32.dll" (ByVal hdc As Long, lpRect As RECT, ByVal hBrush As Long) As Long

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

FrameRect draws a one-pixel-wide frame around a rectangle on a device using a given brush. This frame is equivalent to what the edge of a filled rectangle (using FillRect) would be. Note that this function uses the brush passed to the function, so it is not necessary to use SelectObject to have the device select the brush first. The function returns 1 if successful, or 0 if an error occured.

hdc
A device context to the device to draw the rectangular frame on.
lpRect
The rectangle that defines the rectangular frame to draw.
hBrush
A handle to the brush to use to draw the rectangular frame.

Example:

' Use a blue diagonal-cross hatched brush to draw a rectangular
' frame on window Form1.  The rectangular frame has coordinates (20,25)-(200,175).

Dim hbrush As Long  ' receives handle to the blue hatched brush to use
Dim r As RECT  ' rectangular area to frame
Dim retval As Long  ' return value

' Set the coordinates of the rectangle r
retval = SetRect(r, 20, 25, 200, 175)  ' now r = (20,25)-(200,175)
' Create a blue diagonal-cross hatched brush
hbrush = CreateHatchBrush(HS_DIAGCROSS, RGB(0, 0, 255))
' Fill in the desired rectangular area
retval = FrameRect(Form1.hDC, r, hbrush)  ' frame the rectangle using the brush
' Delete the brush we created in order to free up resources
retval = DeleteObject(hbrush)

See Also: FillRect, FrameRgn
Category: Filled Shapes

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/f/framerect.html