AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Problem mit TColletion zur Designzeit

Ein Thema von static_cast · begonnen am 28. Feb 2005 · letzter Beitrag vom 6. Mär 2005
Antwort Antwort
Seite 1 von 2  1 2      
static_cast

Registriert seit: 19. Okt 2003
Ort: Peine
300 Beiträge
 
#1

Problem mit TColletion zur Designzeit

  Alt 28. Feb 2005, 16:53
Hi,

ich habe ein Problem und zwar versuche ich mit einer TCollection ein TCollectionItems eine Liste zu erstellen die man zur Designzeit im OI bearbeiten kann. Er öffnet einfach nicht das Fenster zum bearbeiten Aber funktionieren tut es soweit ich habe es ausporbiert ich kann zur laufzeits Items erstellen und auf sie zugreifen, nur zur Designzeit geht es nicht.

Der Code ist folgender:

Delphi-Quellcode:
  { TAccount }

  TAccount = class(TCollectionItem)
  private
    FValue: String;
    procedure SetValue(const Value: String);
  protected
  public
    constructor Create(ACollection: TCollection); override;
  published
    property Value:String read FValue write SetValue;
  end;

  { TAccounts }

  TAccounts = class(TCollection)
  private
    FOwner: TPersistent;
    function GetItem(Index: Integer): TAccount;
    procedure SetItem(Index: Integer; Value: TAccount);
  protected
    function GetOwner: TPersistent; override;
  public
    constructor Create(Owner: TPersistent);
    function Add: TAccount;
    property Items[Index: Integer]: TAccount read GetItem write SetItem; default;
  end;

  { TAccountProperties }

  TAccountProperties = class(TPersistent)
  private
    FVisibleAccounts: TAccountTypes;
    FAccounts: TAccounts;
    procedure SetVisibleAccounts(const Value: TAccountTypes);
    procedure SetAccounts(Value: TAccounts);
  protected
  public
    constructor Create;
    destructor Destroy; override;
  published
    property Accounts:TAccounts read FAccounts write SetAccounts;
    property VisibleAccounts:TAccountTypes read FVisibleAccounts write SetVisibleAccounts;
  end;
Delphi-Quellcode:
{ TAccountProperties }

constructor TAccountProperties.Create;
begin
  FAccounts:=TAccounts.Create(Self);
  VisibleAccounts:=atAll;
end;

destructor TAccountProperties.Destroy;
begin
  FreeAndNil(FAccounts);
  inherited;
end;

procedure TAccountProperties.SetAccounts(Value: TAccounts);
begin
  FAccounts.Assign(Value);
end;

procedure TAccountProperties.SetVisibleAccounts(const Value: TAccountTypes);
begin
  FVisibleAccounts:=Value;
end;

{ TAccount }

constructor TAccount.Create(ACollection: TCollection);
begin
  inherited Create(ACollection);
end;

procedure TAccount.SetValue(const Value: String);
begin
  FValue := Value;
end;

{ TAccounts }

function TAccounts.Add: TAccount;
begin
  Result := TAccount(inherited Add);
end;

constructor TAccounts.Create(Owner: TPersistent);
begin
  inherited Create(TAccount);
  FOwner:=Owner;
end;

function TAccounts.GetItem(Index: Integer): TAccount;
begin
  Result := TAccount(inherited GetItem(Index));
end;

function TAccounts.GetOwner: TPersistent;
begin
  Result := FOwner;
end;

procedure TAccounts.SetItem(Index: Integer; Value: TAccount);
begin
  inherited SetItem(Index, Value);
end;
Grüße,
Daniel.

P.S.: bin @work und hier benutzen wir Delphi 5 Pro (wenn das von relevants ist )
Daniel M.
"The WM_NULL message performs no operation. An application sends the WM_NULL message if it wants to post a message that the recipient window will ignore."
  Mit Zitat antworten Zitat
Benutzerbild von Jens Schumann
Jens Schumann

Registriert seit: 27. Apr 2003
Ort: Bad Honnef
1.644 Beiträge
 
Delphi 2009 Professional
 
#2

Re: Problem mit TColletion zur Designzeit

  Alt 28. Feb 2005, 17:11
Hallo,
versuchs es mal mit
Delphi-Quellcode:
constructor TAccountProperties.Create;
begin
  FAccounts:=TAccounts.Create(TAccount); // Der Parameter ist der Unterschied
  VisibleAccounts:=atAll;
end;
I come from outer space to save the human race
  Mit Zitat antworten Zitat
static_cast

Registriert seit: 19. Okt 2003
Ort: Peine
300 Beiträge
 
#3

Re: Problem mit TColletion zur Designzeit

  Alt 28. Feb 2005, 18:31
Hi,

hmmm nun ja:
Zitat:
[Error] TestComponente.pas(83): Incompatible types: 'TPersistent' and 'Class reference'
geht nicht


//Edit: aber eigentlich ist das doch eh egal denn:

Delphi-Quellcode:
constructor TAccounts.Create(Owner: TPersistent);
begin
  inherited Create(TAccount); // <---- hier wird der originale aufgerufen
  FOwner:=Owner;
end;
Daniel M.
"The WM_NULL message performs no operation. An application sends the WM_NULL message if it wants to post a message that the recipient window will ignore."
  Mit Zitat antworten Zitat
Benutzerbild von Jens Schumann
Jens Schumann

Registriert seit: 27. Apr 2003
Ort: Bad Honnef
1.644 Beiträge
 
Delphi 2009 Professional
 
#4

Re: Problem mit TColletion zur Designzeit

  Alt 28. Feb 2005, 18:41
Hallo,
mein Vorschlag kann auch nicht funktionieren. Habe mich in der Zeile vertan.
Kannst Du TAccountProperties im OI sehen?
I come from outer space to save the human race
  Mit Zitat antworten Zitat
Benutzerbild von Jens Schumann
Jens Schumann

Registriert seit: 27. Apr 2003
Ort: Bad Honnef
1.644 Beiträge
 
Delphi 2009 Professional
 
#5

Re: Problem mit TColletion zur Designzeit

  Alt 28. Feb 2005, 18:43
Hallo,
Delphi-Quellcode:
constructor TAccountProperties.Create;
begin
  inherited Create; // fehlt bei Dir
  FAccounts:=TAccounts.Create(Self);
  VisibleAccounts:=atAll;
end;
I come from outer space to save the human race
  Mit Zitat antworten Zitat
static_cast

Registriert seit: 19. Okt 2003
Ort: Peine
300 Beiträge
 
#6

Re: Problem mit TColletion zur Designzeit

  Alt 28. Feb 2005, 19:12
Also TAccountProperties ist im OI zu sehen.

Hier mal der Source der TestCompo womit ich auch gerade hier nebenbei zu Hause teste... ich hab echt keine Idee woran es liegt.
Angehängte Dateien
Dateityp: pas testcomponente_492.pas (3,6 KB, 8x aufgerufen)
Daniel M.
"The WM_NULL message performs no operation. An application sends the WM_NULL message if it wants to post a message that the recipient window will ignore."
  Mit Zitat antworten Zitat
static_cast

Registriert seit: 19. Okt 2003
Ort: Peine
300 Beiträge
 
#7

Re: Problem mit TColletion zur Designzeit

  Alt 1. Mär 2005, 09:01
So ich hab nochmal nachgeschaut und nach einem ganz einfachen Bsp. gesucht, wobei ich einen gut beschriebenen Artikel auf der Borland Seite gefunden habe: http://bdn.borland.com/article/0,1410,16647,00.html

Habe dann mal den Source (von TMyCollectionItem und TMyCollection) genommen und 1 zu 1 in meinen übertragen damit es in TAccountProperties vorhanden ist, Ergebnis: es geht auch nicht, wenn ich im OI TAccountProperties aufklappe und dann TAccounts bearbeiten will passiert nicht, es erscheint einfach kein Fenster zum bearbeiten der Collection.

Kann es sein das eine TCollection nicht in einem TPersistent "funktioniert" wie es mein TAccountProperties ja ist?
Daniel M.
"The WM_NULL message performs no operation. An application sends the WM_NULL message if it wants to post a message that the recipient window will ignore."
  Mit Zitat antworten Zitat
static_cast

Registriert seit: 19. Okt 2003
Ort: Peine
300 Beiträge
 
#8

Re: Problem mit TColletion zur Designzeit

  Alt 2. Mär 2005, 09:25
Keiner weiter eine Idee was des Problems Ursache ist oder sein kann?
Daniel M.
"The WM_NULL message performs no operation. An application sends the WM_NULL message if it wants to post a message that the recipient window will ignore."
  Mit Zitat antworten Zitat
Benutzerbild von maximov
maximov

Registriert seit: 2. Okt 2003
Ort: Hamburg
548 Beiträge
 
Delphi 2005 Professional
 
#9

Re: Problem mit TColletion zur Designzeit

  Alt 2. Mär 2005, 09:36
Ich habs jetzt nicht getestet und ist nur ne vermutung: mach die AccountProperties property mal read-only:
  property AccountProperties:TAccountProperties read FAccountProperties; ohne gewehr.

Und nein ich glaube nicht, das es an TPersistent liegen kann.
mâxîmôv.

{KDT}
  Mit Zitat antworten Zitat
static_cast

Registriert seit: 19. Okt 2003
Ort: Peine
300 Beiträge
 
#10

Re: Problem mit TColletion zur Designzeit

  Alt 2. Mär 2005, 11:01
Es hat nichts gebracht, funktioniert genausowenig!

Aber ich habe es mal versucht ohne TAccountProperties direkt an die Komponente anzubinden und zu nutzen, und siehe da, es geht, warum? Dann muss es ja doch an dem TPersistent bzw an TAccountProperties liegen.
Angehängte Dateien
Dateityp: pas testcomponente_100.pas (3,8 KB, 3x aufgerufen)
Daniel M.
"The WM_NULL message performs no operation. An application sends the WM_NULL message if it wants to post a message that the recipient window will ignore."
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 1 von 2  1 2      


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 12:58 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