AreaFill – Fill an area with a solid color

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 LongConst FLOODFILLBORDER = 0Const FLOODFILLSURFACE = 1' Fill a region using the current color or brush'   OBJ can be a form or a control that exposes'       a device context (eg a picture box)'   X,Y are given in the current system coordinates'' If BORDERCOLOR is specified, fills the area'   enclosed by a border of that color' If BORDERCOLOR is omitted, the area is filled with'   the color now at coordinates (x,y), and any'   different color is considered to a the borderSub 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        ' convert into pixel coordinates        x2 = .ScaleX(X, .ScaleMode, vbPixels)        y2 = .ScaleY(Y, .ScaleMode, vbPixels)                ' save FillStyle and FillColor properties        saveFillStyle = .FillStyle        saveFillColor = .FillColor        ' enforce new properties        .FillStyle = 0        .FillColor = colorCode                If IsMissing(borderColor) Then            ' get color at given coordinates            borderColor = .Point(X, Y)            ' change all the pixels with that color            ExtFloodFill .hDC, x2, y2, borderColor, FLOODFILLSURFACE        Else            ExtFloodFill .hDC, x2, y2, borderColor, FLOODFILLBORDER        End If        ' restore properties        .FillStyle = saveFillStyle        .FillColor = saveFillColor    End WithEnd Sub

Share the Post:
Share on facebook
Share on twitter
Share on linkedin


The Latest

microsoft careers

Top Careers at Microsoft

Microsoft has gained its position as one of the top companies in the world, and Microsoft careers are flourishing. This multinational company is efficiently developing popular software and computers with other consumer electronics. It is a dream come true for so many people to acquire a high paid, high-prestige job

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS