How to Flood Fill (Paint) in VB using ExtFloodFill Windows APIID: Q71103
|
You can fill an area on a window in Visual Basic through a Windows API
function call. Depending on the type of fill to be performed, you can
use the ExtFloodFill function to achieve the desired effect. This
feature is similar to the paint feature found in painting programs.
This information applies to Microsoft Visual Basic programming system
version 1.0 for Windows.
The Windows API ExtFloodFill function call fills an area of the
display surface with the current brush, as shown in the example below.
Declare Function ExtFloodFill Lib "GDI" (ByVal hdc%, ByVal i%,
ByVal i%, ByVal w&, ByVal i%) As Integer
AutoSize = TRUE ' Scale picture to size of imported picture.
ScaleMode = 3 ' Set the scale mode to pixels, not twips
FillColor = &HFF00FF ' This will be the selected fill color.
FillStyle = Solid ' Necessary to create a fill pattern.
Picture = Chess.bmp ' This should be in your Windows directory.
Sub Command1_Click ()
' Make sure that the FillStyle is not transparent.
' crColor& specifies the color for the boundary.
Const FLOODFILLBORDER = 0 ' Fill until crColor& color encountered.
Const FLOODFILLSURFACE = 1 ' Fill surface until crColor& color not
' encountered.
X% = 1
Y% = 1
crColor& = RGB(0, 0, 0)
wFillType% = FLOODFILLSURFACE
Suc% = ExtFloodFill(picture1.hDC, X%, Y%, crColor&, wFillType%)
End Sub
crColor& = RGB(255, 0, 0) 'Color to look for.
wFillType% = FLOODFILLBORDER
Suc% = ExtFloodFill(picture1.hDC, X%, Y%, crColor&, wFillType%)
Additional query words: 2.00 3.00
Keywords :
Version :
Platform :
Issue type :
Last Reviewed: June 22, 1999