Re: Trying to flood-fill an irregular shape
- From: "Karl E. Peterson" <karl@xxxxxxxx>
- Date: Wed, 17 May 2006 12:23:38 -0700
Andy wrote:
I'm trying to get an application running in which a map of a property
development (that's real estate for you US folks) is displayed, and
the individual plots are coloured according to their status.
If you know a point within the polygon, here's a routine (from
http://vb.mvps.org/samples/Flood) that emulates the old QB/PDS Paint method:
Private Declare Function ExtFloodFill Lib "gdi32" (ByVal hDC As Long,
ByVal X As Long, ByVal Y As Long, ByVal crColor As Long, ByVal wFillType As
Long) As Long
' ExtFloodFill style flags
Private Const FLOODFILLBORDER = 0
Private Const FLOODFILLSURFACE = 1
Public Sub Paint(ByVal Canvas As Object, ByVal X As Single, ByVal Y As
Single, ByVal FillColor As Long, Optional ByVal FillStyle As
FillStyleConstants = vbFSSolid, Optional ByVal BorderColor As Long = 0,
Optional ByVal Flags As Long = FLOODFILLBORDER)
Dim xP As Long, yP As Long
Dim oldFillColor As Long
Dim oldFillStyle As Long
' This works with forms and picture controls.
If Not TypeOf Canvas Is Form Then
If Not TypeOf Canvas Is PictureBox Then
' Type mismatch error.
Err.Raise Number:=13, Source:="Paint", _
Description:="Canvas must be either a Form or PictureBox."
Exit Sub
End If
End If
' Convert coordinates to pixels.
xP = Canvas.ScaleX(X, Canvas.ScaleMode, vbPixels)
yP = Canvas.ScaleY(Y, Canvas.ScaleMode, vbPixels)
' Cache current fill attributes, set new.
oldFillColor = Canvas.FillColor
oldFillStyle = Canvas.FillStyle
Canvas.FillColor = FillColor
Canvas.FillStyle = FillStyle
' Flood it!
Call ExtFloodFill(Canvas.hDC, xP, yP, BorderColor, Flags)
' Restore cached fill attributes
Canvas.FillColor = oldFillColor
Canvas.FillStyle = oldFillStyle
End Sub
Later... Karl
--
Working without a .NET?
http://classicvb.org/
.
- Prev by Date: Re: Trying to flood-fill an irregular shape
- Next by Date: Re: Trying to flood-fill an irregular shape
- Previous by thread: Re: Trying to flood-fill an irregular shape
- Next by thread: Re: Update a graphic and save it
- Index(es):
Loading