![]() |
Auf dynamisch erzeugtes Form zeichnen
Moin, ich schreibe grad an einem Programm für die Schule und wollte dieses um ein Formular erweitern. Da nicht alle mit der gleichen Delphi-Version arbeiten, wollte ich das gesamte Formular dynamisch als Klasse erstellen lassen.
Jetzt habe ich gerade das Problem, dass auf das Formular eine Image-Komponente soll, auf die ich was ihm Create des Formulars zeichnen will. Nur leider wird da nichts angezeigt. Mein Verdacht ist jetzt, dass ich dass nicht im constructor machen darf, sondern erst im onactivate etwa. Nur weiss ich nicht, wie ich dem OnActivate-Event des dynamisch erstellelten Forms etwas zuweisen kann. Kann mir da jemand weiterhelfen? :?: Hier mal mein Text bis jetzt:
Delphi-Quellcode:
unit DDRegler;
interface uses forms,Classes,ExtCtrls,Graphics; type TRegler = class(Tobject) private Form: TForm; Image: tImage; public // x,y: real; constructor create(left,top: integer; visible: boolean; Sender: TComponent); end; implementation Constructor TRegler.create(left,top: integer; visible: boolean; Sender: TComponent); begin Form := Tform.create(Sender); Form.Left := left; Form.Top := top; Form.Visible:= visible; with Form do begin Width := 250; Height:= 250; end; image := TImage.Create(Form); with image do begin left := 15; top := 15; width := 150; Height := 150; visible := true; // picture := NIL; end; // of image with image.Canvas do begin brush.color:= clred;// clwhite; pen.color := clwhite; Ellipse(0,0,150,150); end; // of image.canvas end; |
Re: Auf dynamisch erzeugtes Form zeichnen
Es muss Image1.Parent := Form;....
EDIT
Delphi-Quellcode:
with image do
begin left := 15; top := 15; width := 150; Height := 150; visible := true; // picture := NIL; //DAS HIER AUCH picture.bitmap.width := 150; picture.bitmap.height := 150; end; // of image with image.Canvas do begin brush.color:= clred;// clwhite; pen.color := clwhite; Ellipse(0,0,150,150); end; // of image.canvas |
Re: Auf dynamisch erzeugtes Form zeichnen
:wall: Warum einfach, wenns auch kompliziert geht. :duck: Danke.
Edit: Die Parent-Zuweisung war schon genug. |
Alle Zeitangaben in WEZ +1. Es ist jetzt 18:51 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz