Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi Warum ist diese TGraphicControl nicht zu sehen? (https://www.delphipraxis.net/56597-warum-ist-diese-tgraphiccontrol-nicht-zu-sehen.html)

berens 8. Nov 2005 14:39


Warum ist diese TGraphicControl nicht zu sehen?
 
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;

Kroko1999 8. Nov 2005 14:55

Re: Warum ist diese TGraphicControl nicht zu sehen?
 
so sollte es gehen!
Delphi-Quellcode:
type Tblabla= class(TGraphicControl)
  private
  protected
    procedure Paint; override;
  public
    constructor Create(aOwner: TComponent); override;
  end;

implementation

constructor Tblabla.Create(aOwner: TComponent);
begin
  inherited Create(aOwner);
  Height := 100;
  Width := 100;
  ParentColor := false;
  with tlabel.Create(aowner) do begin
    left := 5;
    top := 5;
    width := 2000;
    height := 20000;
    color := clred;
    AutoSize := false;
    parent := Self;
    caption := 'XXXXXXXXXXXXXXXXXXXXXXXXXXX';
    BringToFront;
  end;
//  Align := alClient;

  Color := clYellow;
end;

procedure TBlabla.Paint; override;
begin
  inherited;
  Canvas.Lock;
  canvas.Brush.Color := cllime;
  Canvas.FillRect(rect(10,10,10,10));
  canvas.Unlock;
end;
--------------------------------------------------------
Unit1:
procedure TForm1.FormCreate(Sender: TObject);
begin
  n := Tblabla.Create(Self);
  n.Parent := Self;
end;

berens 8. Nov 2005 15:15

Re: Warum ist diese TGraphicControl nicht zu sehen?
 
Hat geklappt, danke.


Alle Zeitangaben in WEZ +1. Es ist jetzt 00:12 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz