Private Declare Function ExtFloodFill Lib "GDI32" (ByVal hDC As Long, _ ByVal X As Long, ByVal Y As Long, ByVal colorCode As Long, _ ByVal fillType As Long) As Long Const FLOODFILLBORDER = 0 Const FLOODFILLSURFACE = 1
Sub AreaFill(obj As Object, ByVal X As Long, ByVal Y As Long, _ ByVal colorCode As Long, Optional borderColor As Variant) Dim x2 As Long, y2 As Long Dim saveFillStyle As Long Dim saveFillColor As Long With obj x2 = .ScaleX(X, .ScaleMode, vbPixels) y2 = .ScaleY(Y, .ScaleMode, vbPixels) saveFillStyle = .FillStyle saveFillColor = .FillColor .FillStyle = 0 .FillColor = colorCode If IsMissing(borderColor) Then borderColor = .Point(X, Y) ExtFloodFill .hDC, x2, y2, borderColor, FLOODFILLSURFACE Else ExtFloodFill .hDC, x2, y2, borderColor, FLOODFILLBORDER End If
.FillStyle = saveFillStyle .FillColor = saveFillColor End With
End Sub |