Autor Beitrag
mcst09
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 112



BeitragVerfasst: Mo 25.12.06 02:17 
Hallo,

ich habe eine PaintBox die ich zur Laufzeit erstelle. Auf diese PaintBox möchte ich nun ein Label erstellen mit einem Text. Aber leider kann ich zwar den Code kompilieren, aber es ist kein Text auf der PaintBox sichtbar.

Hier der Code:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
lPaintBox := TPaintBox.Create(nil);
...
...

lLabel := TLabel.Create(lPaintBox);
with (lLabel) do begin
  Align       := clClient;
  Caption     := 'blablabla' // oder Text statt Caption, weiss ich jetzt nimma auswendig
  ParentColor := true;
end;


hab jetzt noch versucht den Parent anzugeben, sprich
ausblenden Delphi-Quelltext
1:
Parent := lPaintBox;					

aber laut Compiler ist eine TPaintBox kein TWinControl!
Was ist eine PaintBox dann? Und wie bekomme ich das Label auf die PaintBox??

Dank und Gruß
AXL
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19314
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mo 25.12.06 03:32 
Du musst Parent auf das Formular setzen! Dann musst du evtl. noch dein Label mit BringToFront nach vorne bringen, damit es vor der Paintbox ist und nicht dahinter "versteckt".

Ach so: Und eine PaintBox ist von TGraphicControl abgeleitet und eben nicht von TWinControl. TGraphicControl und TWinControl sind wiederum beide von TControl abgeleitet, haben also denselben Vorfahren.
turboPASCAL
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 193
Erhaltene Danke: 1

Win XP / Vischda
D6 PE / D2005 PE
BeitragVerfasst: Do 16.07.09 21:11 
Ist es wirklich notwendig ein Label auf eine Paintbox zu pappen wenn
doch die Möglichkeit besteht in der Paintbog einfach den Text
per Canvas.Textout() etc. auszugeben ?

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:
var
  pb: TPaintBox;

procedure IrgendwoAmAnfang;
begin
  pb := TPaintBox.create(self);
  try
    pb.parent := self;
    pb.top := 20;
    pb.left := 20;
    pb.width := 120;
    pb.height := 80;
  except
     on e: exception do
       showmessage('Fehler bei dem erstellen der Paintbox: '#13 + e.message);
  end;
end;

procedure ZumEnde;
begin
  if assigned(pb) then freeandnil(pb);
end;

procedure Zwischendurch;
begin
  pb.canvas.font.Color := clred;
  pb.canvas.font.style := [fsBold];
  pb.canvas.Brush.Style := bsClear;
  pb.canvas.TextOut(10,10, timetostr(now));
  pb.canvas.Brush.Style := bsSolid;
end;


... mal so als einfacher lösungsvorschlag ;) ...

_________________
Nein, ich bin nicht der turboPASCAL aus der DP, ich seh nur so aus... :P
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19314
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Do 16.07.09 21:43 
Das in Kombination mit einer OffScreenBitmap, ja. Dann wird der Hintergrund des Texts aus der Bitmap geholt und der Text darüber gezeichnet.
turboPASCAL
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 193
Erhaltene Danke: 1

Win XP / Vischda
D6 PE / D2005 PE
BeitragVerfasst: Do 16.07.09 22:03 
Ja, ich habe Thread Nr. 2 übersehen gehabt. ;)

Ich würde für das "TextCleaning" auch nur einen Teil aus dem Gesamtbild nutzen.
Kommt nun aber darauf an was mcst09 machen möchte in Bezug auf die Graphic in der PaintBox.

_________________
Nein, ich bin nicht der turboPASCAL aus der DP, ich seh nur so aus... :P
ffgorcky
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 573

WIN XP/2000 & 7Prof (Familie:Win95,Win98)

BeitragVerfasst: Fr 17.07.09 11:16 
Also jetzt einfach noch mal zu Deinem ersten Beitrag:
user profile iconmcst09 hat folgendes geschrieben Zum zitierten Posting springen:
Aber leider kann ich zwar den Code kompilieren, aber es ist kein Text auf der PaintBox sichtbar.[/delphi]

Ich hoffe, Du hast in jedem Falle andere Farben für das Bild und den Text an der Stelle...