![]() |
Re: Page control
Code:
{$J+}
Const FarbeX: Integer = 44444; nein das klappt leider auch net. :oops: mfg schniede |
Re: Page control
Delphi-Quellcode:
oder so
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.
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. |
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 |
Re: Page control
Moin Schniede,
ich hab' Dir mal ein Beispiel gebastelt, wie ich es machen würde.
Delphi-Quellcode:
Wobei ich eigentlich die Konstanten noch in eine eigenen Unit auslagern würde.
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. |
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 |
Re: Page control
Moin Schniede,
einen hab' ich noch vergessen: Diese Zeile:
Delphi-Quellcode:
muss noch in das dynamische Erzeugen der Tabsheets eingefügt werden, damit deren Breite stimmt.
Caption := _asTabCaptions[i];
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 22:29 Uhr. |
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