ExtFloodFill Function

Declare Function ExtFloodFill Lib "gdi32.dll" (ByVal hdc As Long, ByVal nXStart As Long, ByVal nYStart As Long, ByVal crColor As Long, ByVal fuFillType As Long) As Long

Platforms

Description & Usage

ExtFloodFill performs a flood fill operation on a device using that device's currently selected brush. The flood fill begins at a single point and extends in all directions until a condition is met. The flood fill can extend either until a certain boundary color is reached or while a certain color is being filled over.

Return Value

If an error occured, the function returns 0 (Windows NT, 2000: use GetLastError to get the error code). If successful, the function returns a non-zero value.

Visual Basic-Specific Issues

None.

Parameters

hdc
A handle to a device context to the device to perform the flood fill on.
nXStart
The x-coordinate of the point to begin the flood fill at.
nYStart
The y-coordinate of the point to begin the flood fill at.
crColor
The RGB value of the color determining the extent of the flood fill operation. Its exact interpretation depends on the flag passed as fuFillType.
fuFillType
One of the following flags specifying how to determine the boundary of the flood fill operation:
FLOODFILLBORDER
Fill from the beginning point in all directions until a boundary of color crColor is reached. The flood fill will cover over any colors within the region which do not have the color of crColor.
FLOODFILLSURFACE
Fill from the beginning point in all directions as long as the fill-in color crColor is encountered. The boundary of the flood fill is made up of any color which is not identical to crColor.

Constant Definitions

Const FLOODFILLBORDER = 0
Const FLOODFILLSURFACE = 1

Example

' This code is licensed according to the terms and conditions listed here.

' Draw a solid green ellipse on window Form1 and fill
' the area outside of it with a diagonally cross-hatched red brush.
Dim hPen As Long, hBrush As Long  ' handles to the pen and brush to be used
Dim hOldPen As Long, hOldBrush As Long  ' handles to the previously selected objects
Dim retval As Long  ' return value

' Create a solid green pen with a width of one pixel.
hPen = CreatePen(PS_SOLID, 0, RGB(0, 255, 0))
' Select it for use in Form1, noting the previous pen.
hOldPen = SelectObject(Form1.hDC, hPen)
' Create a blue diagonally cross-hatched brush.
hBrush = CreateHatchBrush(HS_DIAGCROSS, RGB(0, 0, 255))
' Select it for use in Form1, noting the previous brush.
hOldBrush = SelectObject(Form1.hDC, hBrush)

' Draw an ellipse with bounding rectangle (100,150)-(350, 250)
retval = Ellipse(Form1.hDC, 100, 150, 350, 250)
' Flood fill the area outside the ellipse (use a green boundary)
' starting at the point (25,30) outside the ellipse.
retval = ExtFloodFill(Form1.hDC, 25, 25, RGB(0, 255, 0), FLOODFILLBORDER)

' Select the previously selected pen and brush.
retval = SelectObject(Form1.hDC, hOldPen)
retval = SelectObject(Form1.hDC, hOldBrush)
' Delete the pen and brush to free up resources.
retval = DeleteObject(hPen)
retval = DeleteObject(hBrush)

Category

Bitmaps

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


Last Modified: October 17, 1999
This page is copyright © 1999 Paul Kuliniewicz. Copyright Information Revised October 29, 2000
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/e/extfloodfill.html