Einzelnen Beitrag anzeigen

JnZn558

Registriert seit: 22. Aug 2004
98 Beiträge
 
#12

AW: procedure wird nicht aufgerufen

  Alt 6. Sep 2010, 01:50
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:
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;
hier testanwendung
Delphi-Quellcode:
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.
ich aendere alle properties in objekt inspekter von der komponente in testanwendung nacheinander,

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
Peace on the world

Geändert von JnZn558 ( 6. Sep 2010 um 01:54 Uhr)
  Mit Zitat antworten Zitat