Man ersetze TGraphicControl durch TWinControl und es funktioniert. Warum nicht mit TGraphicControl?
Warum ist diese TGraphicControl nicht zu sehen?
Delphi-Quellcode:
type Tblabla= class(TGraphicControl)
private
public
constructor Create(aOwner: TComponent); override;
end;
implementation
constructor Tblabla.Create(aOwner: TComponent);
begin
inherited Create(aOwner);
if aOwner is TWinControl then begin
Parent := (aOwner as TWinControl);
end;
ControlStyle := [csClickEvents,csCaptureMouse];
Left := 10;
Top := 10;
Height := 100;
Width := 100;
ParentColor := false;
Visible := true;
with tlabel.Create(aowner) do begin
left := 5;
top := 5;
width := 2000;
height := 20000;
color := clred;
AutoSize := false;
parent := (aowner as twincontrol);
caption := 'XXXXXXXXXXXXXXXXXXXXXXXXXXX';
BringToFront;
end;
// Align := alClient;
Color := clYellow;
Self.Parent := aowner as TWinControl;
Self.Show;
Canvas.Lock;
canvas.Brush.Color := cllime;
Canvas.FillRect(rect(10,10,10,10));
canvas.Unlock;
Paint;
Refresh;
update;
BringToFront;
Repaint;
Invalidate;
Self.Parent := aowner as TWinControl;
end;
--------------------------------------------------------
Unit1:
procedure TForm1.FormCreate(Sender: TObject);
begin
n := Tblabla.Create(Self);
n.Parent := Self;
end;