Einzelnen Beitrag anzeigen

Benutzerbild von FriFra
FriFra

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

Eigene Komponente "vergißt" Eigenschaften...

  Alt 1. Okt 2005, 12:01
Wenn ich meine Komponente auf einer Form platziert habe wird KillDuplicates und RealNameEnabled bei jedem öffnen des Projekts auf False gesetzt
Warum werden die Properties nicht gespeichert


Delphi-Quellcode:
unit Fr_LocalMailListView;

interface

uses
  SysUtils, Windows, Classes, Controls, ComCtrls, Graphics, Dialogs,
    Fr_LocalMail, ExtCtrls;

type
  TFr_LocalMailListView = class(TListView)
  private
    { Private-Deklarationen }
    fAbout: string;
    LocalMail: TFr_LocalMail;
    SmallIcons, LargeIcons: TImageList;
    B_All: boolean;
    B_Eudora: boolean;
    B_LotusNotes: boolean;
    B_Netscape: boolean;
    B_Opera: boolean;
    B_Outlook: boolean;
    B_Pegasus: boolean;
    B_TheBat: boolean;
    B_KillDuplicates: boolean;
    B_RealNameEnabled: boolean;
    B_RealNameSimulated: boolean;
    procedure SetAll(const Value: boolean);
    procedure SetEudora(const Value: boolean);
    procedure SetLotusNotes(const Value: boolean);
    procedure SetNetscape(const Value: boolean);
    procedure SetOpera(const Value: boolean);
    procedure SetOutlook(const Value: boolean);
    procedure SetPegasus(const Value: boolean);
    procedure SetTheBat(const Value: boolean);
    procedure SetKillDuplicates(const Value: boolean);
    procedure SetRealNameEnabled(const Value: boolean);
    procedure SetRealNameSimulated(const Value: boolean);
    procedure MyUpdateItems;
  protected
    { Protected-Deklarationen }
    property LargeImages;
    property SmallImages;
  public
    { Public-Deklarationen }
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
  published
    { Published-Deklarationen }
    property Align;
    property Anchors;
    property About: string read fAbout write fAbout;
    property FromAll: Boolean read B_All write SetAll default False;
    property FromEudora: Boolean read B_Eudora write SetEudora default False;
    property FromLotusNotes: boolean read B_LotusNotes write SetLotusNotes
      default False;
    property FromNetscape: boolean read B_Netscape write SetNetscape default
      False;
    property FromOpera: Boolean read B_Opera write SetOpera default False;
    property FromOutlook: boolean read B_Outlook write SetOutlook default False;
    property FromPegasus: Boolean read B_Pegasus write SetPegasus default False;
    property FromTheBat: Boolean read B_TheBat write SetTheBat default False;
    property Hint;
    property KillDuplicates: boolean read B_KillDuplicates write
      SetKillDuplicates default True;
    property RealNameEnabled: boolean read B_RealNameEnabled write
      SetRealNameEnabled default True;
    property RealNameSimulated: boolean read B_RealNameSimulated write
      SetRealNameSimulated default False;
    property ShowHint;
    //property Sorted;
    //property Style;
    procedure SetDefaults;
    property Tag;
    property Text;
    property visible;

    property OnClick;
    property OnContextPopup;
    property OnDblClick;
    property OnDragDrop;
    property OnDragOver;
    property OnEndDock;
    property OnEndDrag;
    property OnEnter;
    property OnExit;
    property OnKeyDown;
    property OnKeyPress;
    property OnKeyUp;
    property OnMouseDown;
    property OnMouseMove;
    property OnMouseUp;
    property OnStartDock;
    property OnStartDrag;

    property BorderStyle;
    property Columns;
    property ColumnClick;
    property HideSelection;
  end;

procedure Register;

implementation

{$R res/ImageList.res}

procedure Register;
begin
  RegisterComponents('FriFra', [TFr_LocalMailListView]);
end;

constructor TFr_LocalMailListView.Create(AOwner: TComponent);
var
  RS: TResourceStream;
  bmp: TBitmap;
  n: integer;
begin
  inherited Create(AOwner);
  RS := nil;
  LocalMail := TFr_LocalMail.Create(Self);
  SetDefaults;
  SmallIcons := TImageList.CreateSize(16, 16);
  LargeIcons := TImageList.CreateSize(32, 32);
  Columns.Add;
  Columns[0].Caption := 'Mail';
  Columns[0].AutoSize := True;
  Columns.Add;
  Columns[1].Caption := 'Application';
  Columns[1].AutoSize := True;
  ReadOnly := True;
  bmp := TBitmap.Create;
  try
    for n := 0 to 6 do
    begin
      try
        RS := TResourceStream.Create(HInstance, 'Large' + IntToStr(n),
          RT_RCDATA);
        RS.Position := 0;
        bmp.LoadFromStream(RS);
        LargeIcons.AddMasked(bmp, clFuchsia);
      finally
        RS.Free;
      end;
      try
        RS := TResourceStream.Create(HInstance, 'Small' + IntToStr(n),
          RT_RCDATA);
        RS.Position := 0;
        bmp.LoadFromStream(RS);
        SmallIcons.AddMasked(bmp, clFuchsia);
      finally
        RS.Free;
      end;
    end;
  finally
    bmp.Free;
  end;
  LargeImages := LargeIcons;
  SmallImages := SmallIcons;
end;

destructor TFr_LocalMailListView.Destroy;
begin
  LocalMail.Free;
  SmallIcons.Free;
  LargeIcons.Free;
  inherited;
end;

procedure TFr_LocalMailListView.SetAll(const Value: boolean);
begin
  B_All := Value;
  if Value = True then
  begin
    LocalMail.FromAll := False;
    SetEudora(True);
    SetLotusNotes(True);
    SetNetscape(True);
    SetOpera(True);
    SetOutlook(True);
    SetPegasus(True);
    SetTheBat(True);
    SetRealNameEnabled(B_RealNameEnabled);
    SetRealNameSimulated(B_RealNameSimulated);
  end;
end;

procedure TFr_LocalMailListView.SetEudora(const Value: boolean);
begin
  if Value = False then
    B_All := False;
  B_Eudora := Value;
  LocalMail.FromEudora := Value;
  MyUpdateItems;
end;

procedure TFr_LocalMailListView.SetLotusNotes(const Value: boolean);
begin
  if Value = False then
    B_All := False;
  B_LotusNotes := Value;
  LocalMail.FromLotusNotes := Value;
  MyUpdateItems;
end;

procedure TFr_LocalMailListView.SetNetscape(const Value: boolean);
begin
  if Value = False then
    B_All := False;
  B_Netscape := Value;
  LocalMail.FromNetscape := Value;
  MyUpdateItems;
end;

procedure TFr_LocalMailListView.SetOpera(const Value: boolean);
begin
  if Value = False then
    B_All := False;
  B_Opera := Value;
  LocalMail.FromOpera := Value;
  MyUpdateItems;
end;

procedure TFr_LocalMailListView.SetOutlook(const Value: boolean);
begin
  if Value = False then
    B_All := False;
  B_Outlook := Value;
  LocalMail.FromOutlook := Value;
  MyUpdateItems;
end;

procedure TFr_LocalMailListView.SetPegasus(const Value: boolean);
begin
  if Value = False then
    B_All := False;
  B_Pegasus := Value;
  LocalMail.FromPegasus := Value;
  MyUpdateItems;
end;

procedure TFr_LocalMailListView.SetTheBat(const Value: boolean);
begin
  if Value = False then
    B_All := False;
  B_TheBat := Value;
  LocalMail.FromTheBat := Value;
  MyUpdateItems;
end;

procedure TFr_LocalMailListView.SetKillDuplicates(const Value: boolean);
begin
  B_KillDuplicates := Value;
  LocalMail.KillDuplicates := Value;
  {SetLotusNotes(B_LotusNotes);
  SetOutlook(B_Outlook);
  SetNetscape(B_Netscape);
  SetOpera(B_Opera);
  SetEudora(B_Eudora);
  SetPegasus(B_Pegasus);
  SetTheBat(B_TheBat);}

  MyUpdateItems;
end;

procedure TFr_LocalMailListView.SetRealNameEnabled(const Value: boolean);
begin
  B_RealNameEnabled := Value;
  LocalMail.RealNameEnabled := Value;
  MyUpdateItems;
end;

procedure TFr_LocalMailListView.SetRealNameSimulated(const Value: boolean);
begin
  B_RealNameSimulated := Value;
  LocalMail.RealNameSimulated := Value;
  MyUpdateItems;
end;

procedure TFr_LocalMailListView.SetDefaults;
begin
  LocalMail.FromAll := B_All;
  LocalMail.FromEudora := B_Eudora;
  LocalMail.FromLotusNotes := B_LotusNotes;
  LocalMail.FromNetscape := B_Netscape;
  LocalMail.FromOutlook := B_Outlook;
  LocalMail.FromOpera := B_Opera;
  LocalMail.FromPegasus := B_Pegasus;
  LocalMail.FromTheBat := B_TheBat;
  LocalMail.KillDuplicates := B_KillDuplicates;
  LocalMail.RealNameEnabled := B_RealNameEnabled;
  LocalMail.RealNameSimulated := B_RealNameSimulated;
end;

procedure TFr_LocalMailListView.MyUpdateItems;
var
  n: integer;
  Item: TListItem;
begin
  Items.BeginUpdate;
  Items.Clear;
  for n := 0 to LocalMail.Mails_Eudora.Count - 1 do
  begin
    Item := Items.Add;
    Item.Caption := LocalMail.Mails_Eudora[n];
    Item.ImageIndex := 0;
    Item.SubItems.Add('Eudora');
  end;
  for n := 0 to LocalMail.Mails_LotusNotes.Count - 1 do
  begin
    Item := Items.Add;
    Item.Caption := LocalMail.Mails_LotusNotes[n];
    Item.ImageIndex := 1;
    Item.SubItems.Add('Lotus Notes');
  end;
  for n := 0 to LocalMail.Mails_Netscape.Count - 1 do
  begin
    Item := Items.Add;
    Item.Caption := LocalMail.Mails_Netscape[n];
    Item.ImageIndex := 2;
    Item.SubItems.Add('Netscape');
  end;
  for n := 0 to LocalMail.Mails_Opera.Count - 1 do
  begin
    Item := Items.Add;
    Item.Caption := LocalMail.Mails_Opera[n];
    Item.ImageIndex := 3;
    Item.SubItems.Add('Opera');
  end;
  for n := 0 to LocalMail.Mails_Outlook.Count - 1 do
  begin
    Item := Items.Add;
    Item.Caption := LocalMail.Mails_Outlook[n];
    Item.ImageIndex := 4;
    Item.SubItems.Add('Outlook');
  end;
  for n := 0 to LocalMail.Mails_Pegasus.Count - 1 do
  begin
    Item := Items.Add;
    Item.Caption := LocalMail.Mails_Pegasus[n];
    Item.ImageIndex := 5;
    Item.SubItems.Add('Pegasus');
  end;
  for n := 0 to LocalMail.Mails_TheBat.Count - 1 do
  begin
    Item := Items.Add;
    Item.Caption := LocalMail.Mails_TheBat[n];
    Item.ImageIndex := 6;
    Item.SubItems.Add('The Bat!');
  end;
  Items.EndUpdate;
end;

end.
Elektronische Bauelemente funktionieren mit Rauch. Kommt der Rauch raus, geht das Bauteil nicht mehr.
  Mit Zitat antworten Zitat