Total Visual SourceBook

Total Visual SourceBook CD and Printed Manual

Microsoft Access/ Office 2016, 2013, 2010, and 2007 Version
is Shipping!

New features in Total Visual SourceBook for Access, Office 2007 and VB6

Supports Access/Office 2016, 2013, 2010 and 2007, and Visual Basic 6.0!

Separate version for Access/Office 2003, 2002, and 2000.

Separate version for:
Access 97/95


View all FMS products for Microsoft AccessAll Our Microsoft Access Products

SourceBook Info:

Why SourceBook?

 

"The code is exactly how I would like to write code and the algorithms used are very efficient and well-documented."

Van T. Dinh, Microsoft MVP

 

 

 

Microsoft Access, Office/VBA, VB6 Modules royalty-free source code libraryMicrosoft Access Modules royalty-free source code libraryMicrosoft Access VBA and VB6 Module Library Free trial of Total Visual SourceBook for Microsoft Access, Office, VB6 and VBA

Class: GDIFloodFill in Category Microsoft Visual Basic 6 : Graphics from Total Visual SourceBook

Class that fills an area using Windows API GDI calls in VB6.

The Windows API FloodFill function fills a region of the form or picture which is bounded by a solid line of pixels of the same color. It is often used to "color in" parts of the form. The routines in this class allow you to use the Windows API FloodFill function.

Procedure List

Procedure Name

Type

Description

(Declarations) Declarations Declarations and private variables for the CGDIFloodFill class
BrushStyle Property Get the current style used to fill the area. The value of this property should be set to one of the Windows API Brush Style constants (BS_SOLID, BS_HOLLOW, BS_HATCHED etc.) which are exposed as EnumFloodFillBrushStyles constants in this class.
FillColor Property Get the current value of the color used for the flood fill
FillStyle Property Get the current value of the style used for the flood fill. The value should be one of 0-FLOODFILLBORDER, or 1-FLOODFILLSURFACE (see the declarations sections of this class for these constants.) If FillStyle is FLOODFILLBORDER, Windows assumes that the area to be filled is completely bounded by the color specified by the FillColor property. The function begins filling at the point specified by the X and Y properties and continues in all directions until it reaches the boundary. If FillStyle is FLOODFILLSURFACE, Windows assumes that the area to be filled is a single color. The function begins to fill the area at the point specified by the X and Y properties, and continues in all directions, filling all adjacent regions containing the color specified by FillColor.
HatchStyle Property Get the current value of the style used for the flood fill when the BrushStyle is set to hatched. The value of this property should be set to one of the Windows API Hatch Style constants (HS_HORIZONTAL, HS_BDIAGONAL, HS_CROSS etc.) which are exposed as EnumFloodFillHatchStyles constants in this class.
x Property Get the location of the horizontal starting point for the flood fill
Y Property Get the location of the vertical starting point for the flood fill
Class_Initialize Initialize Set initial values to defaults which may be overridden with property settings
FloodFill Method Fills an area with a specified color
TranslateVBColor Private Translates VBA/VB6 color constants for system colors into GDI equivalents. VBA/VB6 color constants, such as vbRed, vbBlue, or values returned using the QBColor() or RGB() functions, can be used directly for the color values used with Windows API calls. However, the VBA/VB6 color constants for system colors (vbButtonFace, vb3DShadow etc.) do not map correctly to those expected by Windows. This function accepts either form of constant and translates the value, if necessary, into the equivalent value expected by the Windows GDI subsystem.

Example Code for Using Class: GDIFloodFill

' Example of the CGDIFloodFill class
'
' To try this example, do the following:
' 1. Create a new form
' 2. Paste all the code from this example to the new form's module
' 3. Run the form and click on the background. Two overlapping rectangles
'    are drawn on the form, and the overlapped area is filled

Private Sub Form_Load()
  ' Set scalemode for easy calculation
    Me.ScaleMode = vbInches
    Me.ForeColor = vbRed
End Sub

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, x As Single, Y As Single)

  Dim GDIFloodFill As CGDIFloodFill

  Set GDIFloodFill = New CGDIFloodFill

  ' Erase the form background
    cls

  ' Draw two overlapping rectangles
    Me.Line (X - 0.5, Y - 0.5)-(X + 0.5, Y + 0.5), , B
    Me.Line (X, Y)-(X + 1, Y + 1), , B

  ' Fill the overlapped area with a solid color
    With GDIFloodFill
      .BrushStyle = ffbsBS_SOLID

      .X = ScaleX(X, vbInches, vbPixels) + 5
      .Y = ScaleY(Y, vbInches, vbPixels) + 5

      .FillColor = vbRed
      .FillStyle = ffsFLOODFILLBORDER

      .FloodFill Me.hDC

    End With

  Set GDIFloodFill = Nothing

End Sub

Microsoft Access Module LibraryOverview of Total Visual SourceBook

The source code in Total Visual SourceBook includes modules and classes for Microsoft Access, Visual Basic 6 (VB6), and Visual Basic for Applications (VBA) developers. Easily add this professionally written, tested, and documented royalty-free code into your applications to simplify your application development efforts.

Additional Resources