Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/VCLX/TCanvas    [ Add a report in this area ]  
Report #:  35557   Status: Closed
Canvas.FloodFill fails with system colors when in fsBorder mode
Project:  Delphi Build #:  10.0.2288.42451
Version:    10.0 Submitted By:   Vedran Vuk
Report Type:  Basic functionality failure Date Reported:  10/21/2006 1:57:22 PM
Severity:    Infrequently encountered problem Last Updated: 10/31/2006 11:19:52 AM
Platform:    All versions Internal Tracking #:  
Resolution: Cannot Fix (Resolution Comments) Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: (1 Total Rating)
5.00 out of 5
Total Votes: None
Description
When a shape is drawn using a pen of a system color and then FloodFill(ed) in fsBorder mode with the same system color, the function fails and fills the whole canvas with the brush. If the color constant is used instead of a system color (for instance clRed instead of clHighlight), it works as expected.

// Example

Canvas.Pen.Color := clHighlight;
Canvas.Brush.Style := bsClear;
Canvas.Ellipse(Rect(50, 50, 70, 70));

Canvas.Brush.STyle := bsSolid;
Canvas.Brush.Color := clYellow;
FloodFill(60, 60, clHighLight, fsBorder);
Steps to Reproduce:
See the attached project file for demonstration.
Workarounds
Translate the system color into an RGB-Color using GetSysColor:

Canvas.Pen.Color := GetSysColor(clHighlight);
Canvas.Brush.Style := bsClear;
Canvas.Ellipse(Rect(50, 50, 70, 70));

Canvas.Brush.STyle := bsSolid;
Canvas.Brush.Color := clYellow;
FloodFill(60, 60, GetSysColor(clHighLight), fsBorder);

If you need this to work with all colors (system colors and normal colors), use the ColorToRGB function.
Attachment
FloodFill.zip
Comments

Sebastian Modersohn at 10/28/2006 10:55:56 AM -
This is most likely a limitation of the ExtFloodFill WinAPI which is called by TCanvas.FloodFill. If you always translate the color with ColorToRGB it is easy to circumvent this limitation.
I've added this as a workaround and also modified the area of the report.

Server Response from: ETNACODE01