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



BeitragVerfasst: Mi 22.03.06 00:42 
Hallo,

ich möchte zur Laufzeit ein Panel erzeugen, auf dem eine Paintbox ist (als alCLient). Leider wird bei mir immer nur das graue Panel angezeigt, nicht aber meine blaue Paintbox. Muss man irgendwas beachten??

habe eigentlich ganz einfach nur mein Panel erzeugt (lPanel := TPanel.Create(nil);) und dann die Paintbox (lPaintBox := TPaintBox.Create(nil);
Parent := lPanel;

Es wird auch alles compiliert, also der Code passt.
Nur wird wie gesagt die Paintbox nicht angezeigt.

Wie würde das bei Euch vom Code her ausschauen??

Axl
Kroko
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1284

W98 W2k WXP
Turbo D
BeitragVerfasst: Mi 22.03.06 07:02 
Das "Blaumachen" mußte Du im OnPaint-Ereigniss der PaintBox schreiben! Allerdings bringt TPanel auch eine Canvas mit, vielleicht hilfts!

_________________
Die F1-Taste steht nicht unter Naturschutz und darf somit regelmäßig und oft benutzt werden! oder Wer lesen kann, ist klar im Vorteil!
Vera
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 82

WinXP Home
Delphi 2005 Personal
BeitragVerfasst: Mi 22.03.06 10:32 
Deine Sourcecode Schnippsel lassen leider einige Fragen offen.

Deshalb hier ein Code der funktionieren sollte:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
var
  Panel: TPanel;
  PaintBox: TPaintBox;
begin
  Panel := TPanel.Create (Self);  // Self = Form
  Panel.Parent := Self;

  PaintBox := TPaintBox.Create (Self);
  PaintBox.Parent := Panel;
  PaintBox.Align := alClient;
end;


Probier es doch einfach mal so aus. ;-)

Bye, Vera!
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mi 22.03.06 12:30 
user profile iconmcst09 hat folgendes geschrieben:
Nur wird wie gesagt die Paintbox nicht angezeigt.

Du hast kein parent gesetzt, welcher für das Zeichnen der Komponete verantwortlich ist.
mcst09 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 112



BeitragVerfasst: Mi 22.03.06 15:52 
Titel: Diesmal mit Code
Hallo,

also bei mir schaut das ganze so aus:
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:
  fTempPanel := TPanel.Create(nil);
  fTempPanel.Parent := fMainPanel;
  fTempPanel.Width := lTreeViewWidth;
  fTempPanel.Align := alTop;
  fTempPanel.Top := 3;
  fTempPanel.Color := clBackground;
  fTempPanel.Height := 23;
  fTempPanel.BevelInner := bvNone;
  fTempPanel.BevelOuter := bvRaised;
  fTempPanel.ParentColor := false;
  fTempPanel.FullRepaint := true;

  fDesignPaintBox := TPaintBox.Create(nil);
  fDesignPaintBox.Top := 1;
  fDesignPaintBox.Parent := fTempPanel;
  fDesignPaintBox.Align := alClient;
  fDesignPaintBox.ParentColor := false;
  fDesignPaintBox.Color := clBackground;
  fDesignPaintBox.Height := 21;
  fDesignPaintBox.BringToFront;
  PaintBox1Paint(fDesignPaintBox);
  fDesignPaintBox.Visible := true;


Leider ohne Erfolg, die PaintBox wird nicht angezeigt, das Panel schon.
Die IDE compliliert alles wunderbar.

Axl
Kroko
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1284

W98 W2k WXP
Turbo D
BeitragVerfasst: Mi 22.03.06 16:01 
Titel: Re: Diesmal mit Code
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:
24:
25:
26:
27:
28:
29:
  procedure MyPaint (Sender: TObject);
  begin
    fDesignPaintBox.Canvas.Brush.Color := ClBlue;
    fDesignPaintBox.Canvas.FillRect (fDesignPaintBox.ClientRect);
  end;


  fTempPanel := TPanel.Create(nil);
  fTempPanel.Parent := fMainPanel;
  fTempPanel.Width := lTreeViewWidth;
  fTempPanel.Align := alTop;
  fTempPanel.Top := 3;                           // hä Align zieht stärker
  fTempPanel.Color := clBackground;
  fTempPanel.Height := 23;
  fTempPanel.BevelInner := bvNone;
  fTempPanel.BevelOuter := bvRaised;
  fTempPanel.ParentColor := false;              // geht bei Color := automatisch
  fTempPanel.FullRepaint := true;

  fDesignPaintBox := TPaintBox.Create(fTempPanel);
  fDesignPaintBox.Top := 1;                    // ebenfalls Align zieht stärker
  fDesignPaintBox.Parent := fTempPanel;
  fDesignPaintBox.Align := alClient;
  fDesignPaintBox.ParentColor := false;        // geht bei Color := automatisch
  fDesignPaintBox.Color := clBackground;
  fDesignPaintBox.Height := 21;                // ebenfalls Align zieht stärker
  fDesignPaintBox.BringToFront;
  fDesignPaintBox.OnPaint := MyPaint;          // siehe 1.Beitrag!
  fDesignPaintBox.Visible := true;

_________________
Die F1-Taste steht nicht unter Naturschutz und darf somit regelmäßig und oft benutzt werden! oder Wer lesen kann, ist klar im Vorteil!