Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
 
 
 
 
 
 
 
Old Pages
 
Old Index
Site Map
What's New
 
Books
How To
Tips & Tricks
Tutorials
Stories
Performance
Essays
Links
Q & A
New in VB6
Free Stuff
Pictures
 
 
 
TitleFill an irregular area with the FloodFill API function
Keywordsflood, floodfill
CategoriesGraphics
 
Create and select a brush using the color you want. Use the FloodFill API function to fill the area.
 
Private Sub Form_MouseDown(Button As Integer, Shift As _
    Integer, X As Single, Y As Single)
Dim color As Long
Dim brush As Long
Dim old_brush As Long

    ' Pick a random color other than black and
    ' the point's current color.
    Do
        color = QBColor(Int(15 * Rnd + 1))
    Loop While color = Point(X, Y)

    ' Create and select a brush of this color.
    brush = CreateSolidBrush(color)
    old_brush = SelectObject(hdc, brush)

    ' Do the flood,stopping when we
    ' reach black pixels.
    FloodFill hdc, X, Y, vbBlack

    ' Select the old brush and delete the new one.
    brush = SelectObject(hdc, old_brush)
    DeleteObject brush

    Refresh
End Sub
 
My book Visual Basic Graphics Programming has much more information about using API functions to draw graphics.
 
 
Copyright © 1997-2003 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated