Thema: Delphi Page control

Einzelnen Beitrag anzeigen

Christian Seehase
(Co-Admin)

Registriert seit: 29. Mai 2002
Ort: Hamburg
11.105 Beiträge
 
Delphi 11 Alexandria
 
#14

Re: Page control

  Alt 29. Okt 2003, 23:22
Moin Schniede,

ich hab' Dir mal ein Beispiel gebastelt, wie ich es machen würde.

Delphi-Quellcode:
const
  _iTabCount = 5;
  _aclInitTabColors : array [0.._iTabCount-1] of TColor = (clBlue,clRed,clGreen,clYellow,clWhite);
  _asTabCaptions : array [0.._iTabCount-1] of string = (' Hauptansicht',' Einzelans.- Kunde',' Best. Waren ges.',' Warenlager',' Eigene Umsätze');

type
  TForm1 = class(TForm)
    PageControl1: TPageControl;
    procedure PageControl1DrawTab(Control: TCustomTabControl; TabIndex: Integer; const Rect: TRect; Active: Boolean);
    procedure FormCreate(Sender: TObject);
  private
    { Private-Deklarationen }
    FaclTabColors : array [0.._iTabCount-1] of TColor;
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.PageControl1DrawTab(Control: TCustomTabControl;
  TabIndex: Integer; const Rect: TRect; Active: Boolean);

begin
  Control.Canvas.Brush.Color := FaclTabColors[TabIndex];
  Control.Canvas.FillRect(Rect);
  Control.Canvas.TextOut(Rect.Left+5,Rect.Top+3,_asTabCaptions[TabIndex]);
end;

procedure TForm1.FormCreate(Sender: TObject);

var
  i : integer;

begin
  for i := low(FaclTabColors) to high(FaclTabColors) do begin
    FaclTabColors[i] := _aclInitTabColors[i];
    with TTabSheet.Create(self) do begin
      Parent := PageControl1;
      PageControl := PageControl1;
      Name := 'ts'+IntToStr(i+1);
    end;
  end;
end;

end.
Wobei ich eigentlich die Konstanten noch in eine eigenen Unit auslagern würde.
Tschüss Chris
Die drei Feinde des Programmierers: Sonne, Frischluft und dieses unerträgliche Gebrüll der Vögel.
Der Klügere gibt solange nach bis er der Dumme ist
  Mit Zitat antworten Zitat