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 Property vom Typ TStrings einer neuen Komponente hinzufügen (https://www.delphipraxis.net/4840-property-vom-typ-tstrings-einer-neuen-komponente-hinzufuegen.html)

phlux 13. Mai 2003 22:02


Property vom Typ TStrings einer neuen Komponente hinzufügen
 
Hi!
Also im moment versuche ich einer neuen Komponente eine Property namens Items hinzuzufügen, diese soll vom Typ TStrings bzw. TStringlist sein. Sobald ich jetzt jedoch im Objektinspektor die Property Items modifiziere (sprich: Ich schreibe ein, zwei Strings hinein) und dann das Projekt starte kriege ich Accessviolations und Delphi schmiert ab :(. Woran liegt das?? bzw. wie kann ich die Property richtig implementieren??

Hansa 13. Mai 2003 23:14

Re: Property vom Typ TStrings einer neuen Komponente hinzufü
 
Zitat:

Zitat von phlux
...wie kann ich die Property richtig implementieren??

Wie hast Dus denn bisher versucht :?:

Dezipaitor 14. Mai 2003 09:42

ja das ist typisch delphi,
damit hatte ich auch meine probleme,
und deshal habe ich das tutorial objekteigenschaften.rtf erstellt,
dass man runterladen kann.

http://home.t-online.de/home/5200017...eTutorials.zip

hoffe es hift dir.

phlux 14. Mai 2003 11:10

Re: Property vom Typ TStrings einer neuen Komponente hinzufü
 
Zitat:

Zitat von Hansa
Wie hast Dus denn bisher versucht :?:

also bisher hab ichs so versucht (ich kürze den code jetz mal aufs geringste)

Delphi-Quellcode:
unit ControlTabs;

interface

uses
  Windows, Messages, SysUtils, Classes, Controls, Graphics;

type
  TControlTabs = class(TCustomControl)
  private
    FItems: TStrings;
    procedure SetItems(const Value: TStrings);
    { Private declarations }
  protected
    { Protected declarations }
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
    { Public declarations }
  published
    { Published declarations }
    property Items: TStrings read FItems write SetItems;
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('CR-Soft', [TControlTabs]);
end;

{ TControlTabs }

constructor TControlTabs.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  FItems := TStringList.Create;
end;

procedure TControlTabs.SetItems(const Value: TStrings);
begin
  FItems := Value;
//  SetLength(FButtons, FItems.Count); //FButtons: Array of TRect
end;

destructor TControlTabs.Destroy;
begin
  FItems.Free;
  inherited;
end;

end.

Motzi 14. Mai 2003 11:54

SetItems sollte so ausschaun:
Delphi-Quellcode:
procedure TControlTabs.SetItems(const Value: TStrings);
begin
  FItems.Assign(Value);
end;

phlux 14. Mai 2003 12:05

:hello: danke motzi, klappt wunderbar :thumb:
das passiert wenn man sich ganz faul die prozeduren von delphi schreiben lässt :oops:


Alle Zeitangaben in WEZ +1. Es ist jetzt 18:04 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