Einzelnen Beitrag anzeigen

DelphiCreak

Registriert seit: 3. Sep 2008
51 Beiträge
 
Delphi 2007 Enterprise
 
#7

Re: Canvas / FlodFill-Problem mit eigener Komponente

  Alt 14. Jan 2010, 18:45
Die Paint Methode sieht wie folgt aus:

Delphi-Quellcode:
procedure TTabBar.Paint;
var x: Integer;
begin
  with Canvas do
  begin
  Brush.Color := Color;
  Pen.Color := Color;
  Rectangle(0,0,Width,Height);
  end;
  for x := 1 to TabCaptions.Count do
  if x = TActIndex then
  DrawTab(TActColor, TBColor, Height, 200, (x-1) * 200 + 5*x, true, TTabCaps.Strings[x-1])
  else
  DrawTab(TFColor, TBColor, Height, 200, (x-1) * 200 + 5*x, false, TTabCaps.Strings[x-1]);
end;
und die methode DrawTab:

Delphi-Quellcode:
procedure TTabBar.DrawTab(FillColor, BorderColor: TColor; Height, Width, LeftPos: Integer; Active: Boolean; Caption: String);
begin
  with Canvas do
  begin
  Pen.Width := 2;
  Brush.Color := FillColor;
  Pen.Color := BorderColor;
  Canvas.Font.Assign(Font);
  //Canvas.Brush.Style := bsClear;
  if Active then
  begin

  MoveTo(1+LeftPos,Height);
  LineTo(1+LeftPos, 8);
  Arc(0+LeftPos,1,12+LeftPos,13,9+LeftPos,1,0+LeftPos,10);
  MoveTo(7+LeftPos,2);
  LineTo(Width-7+LeftPos,2);
  Arc(Width-12+LeftPos,1,Width+LeftPos,13,Width+LeftPos,10,Width-9+LeftPos,1);
  MoveTo(Width-1+LeftPos, 8);
  LineTo(Width-1+LeftPos, 1+Height);
  FloodFill(15+LeftPos,7, BorderColor, fsBorder);
  end
  else
  RoundRect(1+LeftPos, 2, 1+Width+LeftPos, Height-3, 9,9);
  Canvas.Pen.Color := Canvas.Font.Color;
  Canvas.TextOut(LeftPos + 20, (Height div 2) - (Canvas.TextHeight(Caption) div 2)-1, Caption);
  end;
end;
Das ganze soll eine "TabBar" werden, wie z.b. die bei Firefox bzw Internet-Explorer, allerdings in Delphi implementiert.

Naja, morgen ist auch noch ein Tag
Dominik C.
  Mit Zitat antworten Zitat