Autor Beitrag
Popov
Gast
Erhaltene Danke: 1



BeitragVerfasst: Fr 24.01.03 22:48 
Ich hab mal ein Tip gesehen in dem gezeigt wurde wie mal die Register von PageControl mahrfarbig darstellen kann. Ich dachte immer, daß ich das auf der Swis Seiten gesehen habe. Ist aber anscheinend nicht so.

Kennt einer den Tip oder weiß wo ich den finden kann.
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Sa 25.01.03 10:34 
folgendes hab ich im EDH2000 gefunden:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
procedure TForm1.PageControl1DrawTab(Control: TCustomTabControl;
TabIndex: Integer; const Rect: TRect; Active: Boolean);
Var l, r: Integer; s: String;
begin
 With Control.Canvas do begin
   case control.tag of
     0: begin
         Brush.Color := clBtnFace;
         Font.Color := clWindowText;
         end;
     1: begin
         Brush.Color := clRed;
         Font.Color := clBlue;
         end;
   FillRect(Rect);
   l := TabIndex;
   s := PageControl1.Pages[TabIndex].Caption;
   l := Rect.left + ((Rect.right - Rect.left - TextWidth(s)) div 2);
   r := Rect.top + ((Rect.bottom - Rect.top - TextHeight('Gg')) div 2);
   TextOut ( l, r, s )
 end
end;


Moderiert von user profile iconChristian S.: Code- durch Delphi-Tags ersetzt

_________________
In the beginning was the word.
And the word was content-type: text/plain.
DorJo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 139



BeitragVerfasst: So 25.05.08 22:27 
=X ... Bei mir kommt bei FillRect(Rect); die Fehlermeldung Konstantenausdruck erwartet :? ar Rect is doch per definition eine Konstante odr?!?!?!!?!?!?!?!? *ANGST*
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: So 25.05.08 23:02 
Hallo!

Schau Dir mal die Case-Anweisung an, die scheint nicht korrekt beendet zu werden.

Grüße
Christian

P.S.: Wenn Du in Zukunft Bemerkungen anderer vermeiden willst, dann solltest Du ein bisschen auf Deine Rechtschreibung achten (und auch auf die Anzahl der Ausrufe- und Fragezeichen ;-))

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
DorJo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 139



BeitragVerfasst: So 25.05.08 23:09 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
procedure TForm1.PageControl1DrawTab(Control: TCustomTabControl;
TabIndex: Integer; const Rect: TRect; Active: Boolean);
Var l, r: Integer; s: String;
begin
 With Control.Canvas do begin
   case control.tag of
     0: begin
         Brush.Color := clBtnFace;
         Font.Color := clWindowText;
         end;
     1: begin
         Brush.Color := clRed;
         Font.Color := clBlue;
         end;
   end;
   FillRect(Rect);
   l := TabIndex;
   s := PageControl1.Pages[TabIndex].Caption;
   l := Rect.left + ((Rect.right - Rect.left - TextWidth(s)) div 2);
   r := Rect.top + ((Rect.bottom - Rect.top - TextHeight('Gg')) div 2);
   TextOut ( l, r, s )
 end
end;


So müsste es doch eigentlich funktionieren oder? Zwar wird das Programm nun einwandfrei kompiliert und ausgeführt, allerdings geschieht nicht das erhoffte :(
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: So 25.05.08 23:13 
Ich habe hier erneut Postings löschen müssen, die nichts mit dem Thema zu tun haben.

Wenn jemand nichts zum Thema beitragen möchte, sondern der Meinung ist, einem anderen Nutzer eine Lektion erteilen zu müssen, dann möge er das per PN tun. Aber nicht hier im Thread!

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: So 25.05.08 23:18 
@Dorjo: Hast Du die Tag-Eigenschaft des Controls entsprechend gesetzt? Die wird ja in der case-Anweisung abgefragt, ob sie Null oder Eins ist.

Ich kann's leider nicht testen, weil ich kein Delphi mehr installiert habe.

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
DorJo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 139



BeitragVerfasst: So 25.05.08 23:21 
Jap. Im Form Create Ereignis auf 1. Damit es rot wird! Aber es passiert nichts :(
Kawa
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 45
Erhaltene Danke: 1



BeitragVerfasst: Di 27.05.08 23:43 
Hallo , falls jemand noch interesse hat,
von DBR Delphi-Ecke

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
 // TTabSheets von TPageControl werden eingefärbt.


// Getestet mit D4 unter WinME

// Variante 1: Tabs dürfen nicht ausgeblendet werden,
//             ansonsten geraten die Reiter durcheinander.

const 
  flaeche: array[0..2] of TColor = (clYellow, clLime, clBlue); 
  schrift: array[0..2] of TColor = (clRed, clBlack, clwhite); 
 
// Farbige Fläche 
procedure TForm1.FormCreate(Sender: TObject); 
var 
  x: integer; 
begin 
  PageControl1.Ownerdraw := true;   // nur bei farbigen Reitern 
  for x := 0 to 2 do 
    PageControl1.Pages[x].brush.color := flaeche[x]; 
end; 
 
// Farbige Reiter 
procedure TForm1.PageControl1DrawTab(Control: TCustomTabControl; 
  TabIndex: Integer; const Rect: TRect; Active: Boolean); 
var 
  r: TRect; 
begin 
  with PageControl1.canvas do begin 
    brush.color := flaeche[TabIndex]; 
    Font.color := schrift[TabIndex]; 
    r := Rect; 
    fillrect(r); 
    Drawtext(handle, Pchar(PageControl1.pages[Tabindex].caption), -1, r, 
      DT_CENTER or DT_VCENTER or DT_SINGLELINE); 
  end; 
end; 

// ----------------------------------------------------------------

// Variante 2: Tabs können ein- und ausgeblendet werden.
//             Bedingung: Es muss eine eigene Prozedur ("TabShow")
//             dafür benutzt werden.

  ... 
  public 
    procedure TabShow(TS: TTabSheet; showtab: boolean); 
  end; 
 
var 
  Form1: TForm1; 
 
implementation 
 
{$R *.DFM} 
 
const 
  TabMaxZahl = 4; 
  flaeche: array[0..TabMaxZahl - 1] of TColor = (clYellow, clFuchsia, clBlue, clGreen); 
  schrift: array[0..TabMaxZahl - 1] of TColor = (clGreen, clBlack, clWhite, clYellow); 
  hlp: array[0..TabMaxZahl - 1] of integer = (0, 1, 2, 3); 
 
procedure TForm1.FormCreate(Sender: TObject); 
var x: integer; 
begin 
  with PageControl1 do begin 
    Ownerdraw := true; 
    if PageCount > TabMaxZahl 
      then begin 
      showmessage('Falsche Tabzahl'); 
      application.terminate; 
      exit; 
    end; 
    for x := 0 to PageCount - 1 do begin 
      Pages[x].tag := x; 
      Pages[x].tabvisible := true; 
      Pages[x].brush.color := flaeche[x]; 
    end; 
  end; 
end; 
 
procedure TForm1.TabShow(TS: TTabSheet; showtab: boolean); 
begin 
  if TS.tabvisible <> showtab then begin 
    if showtab then begin 
      TS.Pagecontrol.ActivePage := TS; // Bugfix 
      TS.tabvisible := true; 
      movememory(@hlp[TS.TabIndex + 1], @hlp[TS.TabIndex], 
        (TabMaxZahl - 1 - TS.TabIndex) * sizeof(integer)); 
      hlp[TS.TabIndex] := TS.tag; 
    end else begin 
      movememory(@hlp[TS.TabIndex], @hlp[TS.TabIndex + 1], 
        (TabMaxZahl - 1 - TS.TabIndex) * sizeof(integer)); 
      TS.tabvisible := false; 
    end; 
  end; 
end; 
 
 
// (Doppelklick im Objektinspektor) 
procedure TForm1.PageControl1DrawTab(Control: TCustomTabControl; 
  TabIndex: Integer; const Rect: TRect; Active: Boolean); 
var 
  r: TRect; 
begin 
  with TPageControl(Control), Canvas do begin 
    brush.color := flaeche[hlp[TabIndex]]; 
    Font.color := schrift[hlp[TabIndex]]; 
    r := Rect; 
    fillrect(r); 
    Drawtext(handle, Pchar(Pages[hlp[TabIndex]].caption), -1, r, 
      DT_CENTER or DT_VCENTER or DT_SINGLELINE); 
  end; 
end; 
 
 
// --- Beispielaufrufe --- 
 
procedure TForm1.Button1Click(Sender: TObject); 
begin 
  TabShow(TabSheet2, false); 
end; 
 
procedure TForm1.Button2Click(Sender: TObject); 
begin 
  if PageControl1.Pagecount = 0 then exit; 
  TabShow(PageControl1.Pages[PageControl1.Pagecount - 1], 
    not PageControl1.Pages[PageControl1.Pagecount - 1].tabvisible); 
end;


Moderiert von user profile iconNarses: Code- durch Delphi-Tags ersetzt
DorJo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 139



BeitragVerfasst: Sa 07.06.08 20:15 
DANKE! Es funktioniert einwandfrei! Ihr habt mir wirklich geholfen (mal von einem abgesehen)!

Mit freundlichen Grüßen

DorJo
Ist die Frage beantwortet? Das Problem gelöst?

Dann klicke hier, um das Thema entsprechend zu markieren!