Autor Beitrag
wisher
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 54
Erhaltene Danke: 1



BeitragVerfasst: Do 16.11.06 17:32 
Hallo,

Ich habe mir eine Routine gabaut, die so eine Art Header auf einem Panel zeichnet.
Jetzt steh ich aber vor dem Problem, dass ich auf dem Header einen Text ausgeben muss.
Dies darf mir aber natürlich den Farbverlauf nicht "kaputt" machen. Weder über ein Label
noch über ein ...Canvas.TextOut(...) bekomme ich das korrekt hin. Entweder übermalt mir
der Text den Farbverlauf, oder der Farbverlauf übermalt mir den Text.

Hat jemand eine Idee ? Anbei mein bisheriger Quellcode. Sollte in jedem Delphi funktionieren.
Ich benutze Delphi 7.


Danke
Sascha


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:
procedure TForm1.DrawIt;
var
 Panel : TPanel;
 hoehe_Kopf : Integer;

 Y, R, G, B: Integer;
 ix : Integer;

 RColor1, GColor1, BColor1: Integer;
 RColor2, GColor2, BColor2: Integer;

 RColor3, GColor3, BColor3: Integer;
 RColor4, GColor4, BColor4: Integer;

 Color1,Color2,Color3,Color4  : TColor;

begin
   (* Das Panel kreieren *)
   Panel := TPanel.Create(self);
   Panel.Parent := self;
   Panel.BevelInner := bvLowered;
   Panel.BevelOuter := bvRaised;
   Panel.Height := 337;
   Panel.Width := 337;
   Panel.Color := clwhite;
   Panel.Left := 50;
   Panel.Top := 50;
   Panel.Repaint;


   (*Farbverlauf I*)
   Color1:=ColorToRGB($00FDF8F2);
   Color2:=ColorToRGB($00F1D5B8);

   RColor1:=GetRValue(Color1);
   GColor1:=GetGValue(Color1);
   BColor1:=GetBValue(Color1);

   RColor2:=GetRValue(Color2);
   GColor2:=GetGValue(Color2);
   BColor2:=GetBValue(Color2);


   (*Farbverlauf II*)
   Color3:=ColorToRGB($00EDC69E);
   Color4:=ColorToRGB($00F1D5B8);

   RColor3:=GetRValue(Color3);
   GColor3:=GetGValue(Color3);
   BColor3:=GetBValue(Color3);

   RColor4:=GetRValue(Color4);
   GColor4:=GetGValue(Color4);
   BColor4:=GetBValue(Color4);

   TMyPanel(Panel).Canvas.Pen.Width:=1;
   TMyPanel(Panel).Canvas.Pen.Style:=psInsideFrame;

   ix := 0;

   hoehe_Kopf := 25;

   for Y:= Panel.ClientRect.Top to hoehe_Kopf do
   begin

     If y <= (hoehe_Kopf div 2 ) then begin
        R:=Round(RColor1 + ((RColor2 - RColor1) * Y / ((hoehe_Kopf div 2 ) - Panel.ClientRect.Top)));
        G:=Round(GColor1 + ((GColor2 - GColor1) * Y / ((hoehe_Kopf div 2 )- Panel.ClientRect.Top)));
        B:=Round(BColor1 + ((BColor2 - BColor1) * Y / ((hoehe_Kopf div 2 )- Panel.ClientRect.Top)));
     end else begin
        inc(ix);
        R:=Round(RColor3 + ((RColor4 - RColor3) * ix / (hoehe_Kopf - (hoehe_Kopf div 2 ))));
        G:=Round(GColor3 + ((GColor4 - GColor3) * ix / (hoehe_Kopf- (hoehe_Kopf div 2 ))));
        B:=Round(BColor3 + ((BColor4 - BColor3) * ix / (hoehe_Kopf- (hoehe_Kopf div 2 ))));
     end;

    TMyPanel(Panel).Canvas.Brush.Color:=RGB(R, G, B);
    TMyPanel(Panel).Canvas.FillRect(Classes.Rect(Panel.ClientRect.Left, Y, Panel.ClientRect.Right, Y+1));

   end;
end;

Für diesen Beitrag haben gedankt: Jakane
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 480

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Do 16.11.06 18:06 
Hast du schonmal Canvas.Brush.Style := bsClear; ausprobiert? Das sollte den Text mit transparentem Hintergrund zeichnen.

_________________
We are, we were and will not be.
wisher Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 54
Erhaltene Danke: 1



BeitragVerfasst: Fr 17.11.06 09:34 
Super, vielen Dank !
wisher Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 54
Erhaltene Danke: 1



BeitragVerfasst: Fr 17.11.06 17:27 
Ich habe noch das Problem, dass das Resize des Panels relativ lange dauert.
Kann man erzwingen, dass das Paint erst ausgeführt, wenn schon geresizet wurde ?
Wenn ein Formular mit mehreren dieser Panels groß und klein gezogen wird und
immer wieder alles neu gezeichnet wird, kostet das natürlich Performance.


Thanx
Sascha