Frage

ich habe ein kleines Problem. Ich versuche, eine TPaintBox auf einem TPanel wie diese zu erstellen:

procedure TForm1.mkPaint(S: string);
var PB: TPaintBox;
begin
  PB := TPaintBox.Create(Self);
  with PB do 
  begin
    Parent := Panel1;
    Visible := True;
    Name := S;
    Height := 100;
    Width := 100;
    Left := 8;
    Top := 8;
    // ParentColor := False;
    Brush.Style := bsSolid;
    Brush.Color := $00000000;
  end;
  Application.ProcessMessages;
end;

Nun, wenn ich die Eltern zu Form1 PaintBox ändern, ich kann die Bürste sehen. Aber mit den Eltern zu Panel1 geändert, geschieht nichts. Jede Idee, wie kann ich dieses Problem beheben?

Vielen Dank im Voraus!

Keine korrekte Lösung

Andere Tipps

Ist das TPanel sichtbar zu beginnen?

Auch dann, wenn TPaintBox keine öffentliche Brush Eigenschaft hat (vielleicht Sie von TShape denken?). Twincontrol tut, aber TPaintBox ist kein Nachkomme Twincontrol. Es ist ein TGraphicControl Nachkomme.

Ja, das war ein Fehler von mir. Ich änderte den Code an:

  pb := TPaintBox.Create(self);
  with pb do begin
    Parent := Form1;
    Visible := true;
    Top := 1;
    Left := 1;
    Width := 250;
    Height := 100;
    ParentColor := false;
    Canvas.Brush.Color := clBlack;
    Canvas.Font.Size := 12;
    Canvas.Font.Color := clWhite;
    Canvas.FillRect(ClientRect);
    Canvas.TextOut(1, 1, 'test');
  end;

aber ohne Erfolg .. Ich meine, wenn ich in das Formular ein PaintBox Komponente fallen dann die Code-Effekt nimmt, wie es tun sollte, aber dynamisch eine TPaintBox zu schaffen .... Keine Ahnung.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top