![]() |
AW: procedure wird nicht aufgerufen
Wir sehen hier aber nicht ein Gramm Code, wo DrawOwn etwas zugewiesen wird!
Wir sehen nur die Deklaration, aber nicht wie es benutzt wird. |
AW: procedure wird nicht aufgerufen
also ich hab jez ein beispiel von delphi.about.com
ich hab zum testen code reingeschrieben, hier kann ich euch zeigen was ich gemeint hab hier komponente quellcode
Delphi-Quellcode:
hier testanwendung
unit ExpandingComponent;
interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, OurCollection; type TExpandingRecord = class(TPersistent) private FIntegerProp : Integer; FStringProp : String; FCollectionProp : TOurCollection; procedure SetCollectionProp(const Value: TOurCollection); public constructor Create(AOwner : TComponent); destructor Destroy; override; procedure Assign(Source : TPersistent); override; published property IntegerProp : Integer read FIntegerProp write FIntegerProp; property StringProp : String read FStringProp write FStringProp; property CollectionProp : TOurCollection read FCollectionProp write SetCollectionProp; end; TExpandingComponent = class(TComponent) private { Private declarations } FProperty1, FProperty2, FProperty3 : TExpandingRecord; FTest: string; protected { Protected declarations } procedure SetProperty1(const Value : TExpandingRecord); procedure SetProperty2(const Value : TExpandingRecord); procedure SetProperty3(const Value : TExpandingRecord); procedure SetTest( str: string ); public { Public declarations } constructor Create(AOwner : TComponent); override; destructor Destroy; override; published { Published declarations } property Property1 : TExpandingRecord read FProperty1 write SetProperty1; property Property2 : TExpandingRecord read FProperty2 write SetProperty2; property Property3 : TExpandingRecord read FProperty3 write SetProperty3; property testproperty: string read FTest write SetTest; end; procedure Register; implementation procedure Register; begin RegisterComponents('Samples', [TExpandingComponent]); end; { TExpandingRecord } procedure TExpandingRecord.Assign(Source: TPersistent); begin if Source is TExpandingRecord then with TExpandingRecord(Source) do begin Self.IntegerProp := IntegerProp; Self.StringProp := StringProp; Self.CollectionProp := CollectionProp; //This actually assigns end else inherited; //raises an exception end; constructor TExpandingRecord.Create(AOwner : TComponent); begin inherited Create; FCollectionProp := TOurCollection.Create(AOwner); end; destructor TExpandingRecord.Destroy; begin FCollectionProp.Free; inherited; end; procedure TExpandingRecord.SetCollectionProp(const Value: TOurCollection); begin FCollectionProp.Assign(Value); end; { TExpandingComponent } constructor TExpandingComponent.Create(AOwner: TComponent); begin inherited; FProperty1 := TExpandingRecord.Create(Self); FProperty2 := TExpandingRecord.Create(Self); FProperty3 := TExpandingRecord.Create(Self); end; destructor TExpandingComponent.Destroy; begin FProperty1.Free; FProperty2.Free; FProperty3.Free; inherited; end; procedure TExpandingComponent.SetProperty1(const Value: TExpandingRecord); begin ShowMessage('Property1'); FProperty1.Assign(Value); end; procedure TExpandingComponent.SetProperty2(const Value: TExpandingRecord); begin ShowMessage('Property2'); FProperty2.Assign(Value); end; procedure TExpandingComponent.SetProperty3(const Value: TExpandingRecord); begin ShowMessage('Property3'); FProperty3.Assign(Value); end; procedure TExpandingComponent.SetTest(str: string); begin ShowMessage('testproperty'); FTest := str; end;
Delphi-Quellcode:
ich aendere alle properties in objekt inspekter von der komponente in testanwendung nacheinander,
unit Unit1;
interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExpandingComponent; type TForm1 = class(TForm) ExpandingComponent1: TExpandingComponent; private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} end. Property1 bis Property3 zeigen leider keine Meldung, also nur bei testproperty gibt es eine meldung "testproperty" aus, und breakpoint haelt auch nur bei testproperty an, property1 bis property3 ignorieren breakpoint, es macht mich voll verrueckt. is das normal? ich hoffe ihr koennt mich jez viel besser verstehen |
AW: procedure wird nicht aufgerufen
Ich wiederhole mich nur ungern, aber in deinem Posting ist wieder keine Zeile Code die zeigt wie auf die Properties auch zugegriffen wird. Warum lässt Du den interessanten Teil immer weg? Diesmal hast Du in Deiner "Testanwendung" ja nicht mal mehr eine Instanz der Klasse TExpandingComponent erzeugt. Es wird also nicht mehr was Du uns zeigst, sondern immer weniger. Falsche Richtung...
|
AW: procedure wird nicht aufgerufen
Zitat:
|
AW: procedure wird nicht aufgerufen
Durch Rumgeschnauze wird Dein Posting auch nicht besser. Die Frage bleibt weiterhin warum Du keinen Code zeigst der mit deiner selbstgebauten Klasse auch arbeitet. Wenn Du da über den Objektinspektor Sachen zuweist, solltest Du noch die entsprechenden Snippets aus dem *.DFM mit einstellen, Kristallkugeln sind gerade aus. Ansonsten zeig mal endlich Code der mit den Properties auch arbeitet. Nicht die Setter hinter den Properties, sondern Code der "von außen" auf die Properties zugreift. Denn davon ist bislang trotz mehrfacher Nachfrage nix zu sehen. Sollte das zu schwer sein, kannst Du auch einfach mal dein komplettes Projekt in ein ZIP-Archiv packen und hier einstellen.
|
AW: procedure wird nicht aufgerufen
Der Setter wird nur dann aufgerufen, wenn die öffentliche Property einen neuen Wert zugewiesen bekommt und nicht dann, wenn die Klasse selbst auf das dahinterliegende private Feld zugreift. Und Ersteres hat man bislang in keinem der gezeigten Codes zu sehen bekommen.
|
AW: procedure wird nicht aufgerufen
ich hab es nun geschafft
Delphi-Quellcode:
oh man, hab mich voll durchgequaelt. danke fuer alle muehe, mir tipps zugeben
unit Unit1;
interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExpandingComponent; type TForm1 = class(TForm) ExpandingComponent1: TExpandingComponent; procedure FormCreate(Sender: TObject); private { Private declarations } tes: TExpandingRecord; public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.FormCreate(Sender: TObject); begin tes := TExpandingRecord.Create( Self ); ExpandingComponent1.Property1.StringProp := 'mach mal das was ich will'; ExpandingComponent1.Property1 := tes; // erst bei dieser zeile springt eine meldung aus end; |
AW: procedure wird nicht aufgerufen
Zitat:
Zitat:
Und beim zweiten Zugriff wird dann der "richtige" Setter angezogen und Deine Message ausgegeben. |
Alle Zeitangaben in WEZ +1. Es ist jetzt 21:20 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 by Thomas Breitkreuz