AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Sprachen und Entwicklungsumgebungen Sonstige Fragen zu Delphi Delphi Problem bei Komponentenerstellung... (Property -> TStrings)
Thema durchsuchen
Ansicht
Themen-Optionen

Problem bei Komponentenerstellung... (Property -> TStrings)

Ein Thema von FriFra · begonnen am 3. Okt 2003 · letzter Beitrag vom 3. Okt 2003
 
Benutzerbild von FriFra
FriFra

Registriert seit: 19. Apr 2003
1.291 Beiträge
 
Delphi 2005 Professional
 
#1

Problem bei Komponentenerstellung... (Property -> TString

  Alt 3. Okt 2003, 11:34
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.
Elektronische Bauelemente funktionieren mit Rauch. Kommt der Rauch raus, geht das Bauteil nicht mehr.
  Mit Zitat antworten Zitat
 


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 05:45 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