![]() |
Problem bei Komponentenerstellung... (Property -> TString
Ich bin gerade dabei eine Komponente zu erstellen. Diese Komponente soll eine Property (read only) vom Typ TStrings haben.
Ich will den entspr. Wert automatisch beim verändern einzelner anderer Properties neu zuweisen. Mein Problem ist nun, wie binde ich eine derartige Property richtig ein, besonders wo erzeuge ich die TString und wo gebe ich sie wieder frei? Bisher habe ich nur ein paar boolean Properties (read write) und eine publisched function drin. Ausserdem ist mir aufgefallen, dass die Defaultwerte der boolschen Properties zwar korrekt auf True stehen, aber nach Einfügen der Komponente jeweils noch False ausgewählt ist...
Delphi-Quellcode:
unit GetLocalMail;
interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Dialogs, StdCtrls, Registry, IniFiles, ActiveX, ShlObj, shellApi, XPMan, ComCtrls, ComObj; type TGetLocalMail = class(TComponent) private { Private-Deklarationen } B_IFN: boolean; B_LN: boolean; B_OL: boolean; B_NS: boolean; B_OP: boolean; L_Mails:TStrings; procedure SetIFN(const Value: boolean); procedure SetLN(const Value: boolean); procedure SetOL(const Value: boolean); procedure SetNS(const Value: boolean); procedure SetOP(const Value: boolean); protected { Protected-Deklarationen } function GetNotesMail: string; function GetOutlookMail: string; function GetNetscapeMail: string; function GetOperaMail: string; public { Public-Deklarationen } published { Published-Deklarationen } property IncludeFullname: boolean read B_IFN write SetIFN default True; property LotusNotes: boolean read B_LN write SetLN default True; property Outlook: boolean read B_OL write SetOL default True; property Netscape: boolean read B_NS write SetNS default True; property Opera: Boolean read B_OP write SetOP default True; property MailAddresses: TStringList read L_Mails; function GetMail: string; end; procedure Register; implementation procedure Register; begin RegisterComponents('FriFra', [TGetLocalMail]); end; procedure TGetLocalMail.SetIFN(const Value: boolean); begin B_IFN := Value; end; procedure TGetLocalMail.SetLN(const Value: boolean); begin B_LN := Value; end; procedure TGetLocalMail.SetOL(const Value: boolean); begin B_OL := Value; end; procedure TGetLocalMail.SetNS(const Value: boolean); begin B_NS := Value; end; procedure TGetLocalMail.SetOP(const Value: boolean); begin B_OP := Value; end; { B E G I N N - Lotus Notes } function TGetLocalMail.GetNotesMail: string; begin Result := 'dummy@dummy.com'; end; { E N D E - Lotus Notes } { B E G I N N - Outlook und Outlook Express } function TGetLocalMail.GetOutlookMail: string; begin Result := 'dummy@dummy.com'; end; { E N D E - Outlook und Outlook Express } { B E G I N N - Netscape } function TGetLocalMail.GetNetscapeMail: string; begin Result := 'dummy@dummy.com'; end; { E N D E - Netscape } { B E G I N N - Opera 5-7 } function TGetLocalMail.GetOperaMail: string; begin Result := 'dummy@dummy.com'; end; { E N D E - Opera 5-7 } { B E G I N N - Mailadressen ausgeben } function TGetLocalMail.GetMail: string; var Tmp, Tmp1: string; begin Result:=''; if B_LN = True then Result := GetNotesMail; end; if B_OL = True then Result := Result + ',' + GetOutlookMail; if B_NS = True then Result := Result + ',' + GetNetscapeMail; if B_OP = True then Result := Result + ',' + GetOperaMail; Result := StringReplace(Result, ',,', ','); if copy(Result, 1, 1) = ',' then Result := copy(Result, 2, Length(Result)); if copy(Result, Length(Result), 1) = ',' then Result := copy(Result, 1, Length(Result) - 1); end; { E N D E - Mailadressen ausgeben } end. |
Re: Problem bei Komponentenerstellung... (Property -> TSt
Zitat:
Zitat:
|
Re: Problem bei Komponentenerstellung... (Property -> TSt
Und wie überschreibe ich den Constructor und Destructor meiner Komponente?
|
Re: Problem bei Komponentenerstellung... (Property -> TSt
:hi:
Ich darf Sakura zitieren: Zitat:
Edit :: ![]() |
Re: Problem bei Komponentenerstellung... (Property -> TSt
Delphi-Quellcode:
[...]
type TGetLocalMail = class(TComponent) public constructor create(AOwner: TComponent); override; destructor destroy; override; [...]
Delphi-Quellcode:
constructor TGetLocalMail.create(AOwner: TComponent);
begin inherited create(AOwner); mystrings := TStrings.create; end; destructor TGetLocalMail.destroy; begin mystrings.free; inherited destroy; end; |
Re: Problem bei Komponentenerstellung... (Property -> TSt
Moin SirThornberry,
wenn Du jetzt noch aus den TStrings eine TStringList machst ist's perfekt ;-) |
Alle Zeitangaben in WEZ +1. Es ist jetzt 10:13 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