Autor Beitrag
cscp
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 49



BeitragVerfasst: Di 06.01.04 22:39 
hi
ich bekomme immer die fehlermeldung: element '' hat kein übergeordnetes fenster... wenn ich etwas mit canvas zeichnen will...

hier der code:
ausblenden volle Höhe 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:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
unit ObjektBox;

interface

uses
  SysUtils, Classes, Controls, Graphics;

type
  TImportance = (Mittel, Hoch, Niedrig);
  TVisible = set of (Glyph, Wichtigkeit);
  TObjektBox = class(TGraphicControl)
  private
    x,y,x2,y2: integer;
    importance: TImportance;
    visible: TVisible;
    title,subtitle:string;
    symbol:TBitmap;

    procedure SetTitle(title:string);
  protected
    procedure Paint;override;
  public
    constructor Create(AOwner:TComponent);
  published
    property Left   :Integer Read x Write x;
    property Top    :Integer Read y Write y;
    property Width  :Integer Read x2 Write x2;
    property Height :Integer Read y2 Write y2;

    property Wichtigkeit  : TImportance Read importance Write importance;
    property Glyph        : TBitmap Read symbol Write symbol;

    property Titel      :String Read title Write setTitle;
    property Untertitel :String Read subtitle Write subtitle;

    property Optionen :TVisible read visible Write visible;
  end;

procedure Register;

implementation

constructor TObjektBox.Create(AOwner:TComponent);
begin
  inherited Create(AOwner);
  x:=0;y:=0;
  x2:=100;y2:=50;
  //TEST ZEICHNUNG
  Canvas.Ellipse(10,10,50,50);
end;

procedure Register;
begin
  RegisterComponents('Eigene', [TObjektBox]);
end;

procedure TObjektBox.Paint;
begin
  with canvas do begin
    pen.Color:=clgray;
    brush.Color:=clwhite;

    Rectangle(x,y,x2,y2);
  end;
end;

procedure TObjektBox.setTitle(title:string);
begin
  inherited Paint;
  Canvas.TextOut(15,(y2-y) div 5,title);
end;

end.


weiss jemand was da falsch ist?
danke
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Mi 07.01.04 10:27 
Hat das Objekt denn einen Parent? Wie erstellst du das Objekt? Zur Entwurfszeit (in der IDE) oder erst zur Laufzeit (per Code)?

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
cscp Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 49



BeitragVerfasst: Mi 07.01.04 17:28 
hab beides versucht immer die gleiche meldung... bei der laufzeit dann mit box.parent:=form1...
CW
Hält's aus hier
Beiträge: 2

WIN 7
D2010 Prof
BeitragVerfasst: Di 13.01.04 23:12 
Titel: Tests sind manchmal fehl am Platze.....
Lass mal in deinem constructor den

//TEST ZEICHNUNG
Canvas.Ellipse(10,10,50,50);

komplett raus, dann müßte es klappen, jedenfalls bei mir.
Ich nehme an, zu diesem frühen Zeitpunkt zerschießt du dir irgendwas.
Oder das canvas Objekt existiert noch garnicht.
:D
Gruß CW