Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi Page control (https://www.delphipraxis.net/11026-page-control.html)

schniede 30. Okt 2003 00:01

Re: Page control
 
Code:
{$J+}
Const FarbeX: Integer = 44444;

nein das klappt leider auch net. :oops:

mfg schniede

himitsu 30. Okt 2003 00:02

Re: Page control
 
Delphi-Quellcode:
Unit Unit1;

Interface
  Uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs;

  Type TForm1 = Class(TForm)
      Procedure FormCreate(Sender: TObject);
      Procedure PageControlDrawTab(Control: TCustomTabControl; TabIndex: Integer; Const Rect: TRect; Active: Boolean);
    Private
      _clTabColors: Array[0..4] of TColor;
    End;

  Var Form1: TForm1;

Implementation
  {$R *.dfm}

  Procedure TForm1.FormCreate(Sender: TObject);
    Begin
      _clTabColors[0] := Farbe11;
      _clTabColors[1] := Farbe12;
      _clTabColors[2] := Farbe13;
      _clTabColors[3] := Farbe14;
      _clTabColors[4] := Farbe15;
    End;

  Procedure TForm1.PageControlDrawTab(Control: TCustomTabControl; TabIndex: Integer; Const Rect: TRect; Active: Boolean);
    Const _sTabCaptions: Array[0..4] of Otring = ('    Hauptansicht', ' Einzelans.- Kunde', ' Best. Waren ges.', '      Warenlager', ' Eigene Umsätze');

    Begin
      Control.Canvas.Brush.Color := _clTabColors[TabIndex];
      Control.Canvas.FillRect(Rect);
      Control.Canvas.TextOut(Rect.Left+5,Rect.Top+3,_sTabCaptions[TabIndex]);
    End;

End.
oder so

Delphi-Quellcode:
Unit Unit1;

Interface
  Uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs;

  Type TForm1 = Class(TForm)
      Procedure FormCreate(Sender: TObject);
      Procedure PageControlDrawTab(Control: TCustomTabControl; TabIndex: Integer; Const Rect: TRect; Active: Boolean);
    End;

  Var Form1: TForm1;
    _clTabColors: Array[0..4] of TColor;

Implementation
  {$R *.dfm}

  Procedure TForm1.FormCreate(Sender: TObject);
    Begin
      _clTabColors[0] := Farbe11;
      _clTabColors[1] := Farbe12;
      _clTabColors[2] := Farbe13;
      _clTabColors[3] := Farbe14;
      _clTabColors[4] := Farbe15;
    End;

  Procedure TForm1.PageControlDrawTab(Control: TCustomTabControl; TabIndex: Integer; Const Rect: TRect; Active: Boolean);
    ...
End.

schniede 30. Okt 2003 00:21

Re: Page control
 
Also was soll ich sagen bin echt sprachlos!

Danke es funzt. :roll:


bis auf dein kleinen Schreibfehler.

Code:
 Const _sTabCaptions: Array[0..4] of Otring ('    Hauptansicht', ' Einzelans.- Kunde', '

Nun kann ich beruhigt schlafen gehen.

Nochmal Danke himitsu !! mfg schniede

Christian Seehase 30. Okt 2003 00:22

Re: Page control
 
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.

schniede 30. Okt 2003 00:27

Re: Page control
 
He Ihr seid echt klasse jetzt kann ich mir gleich mehr Varianten auswählen.

Danke Christian und himitsu habt ihr super gemacht.

So nu sieht es auch gleich gut aus :roll:

mfg schniede

Christian Seehase 30. Okt 2003 00:30

Re: Page control
 
Moin Schniede,

einen hab' ich noch vergessen:

Diese Zeile:
Delphi-Quellcode:
Caption    := _asTabCaptions[i];
muss noch in das dynamische Erzeugen der Tabsheets eingefügt werden, damit deren Breite stimmt.


Alle Zeitangaben in WEZ +1. Es ist jetzt 22:29 Uhr.
Seite 2 von 2     12   

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz