![]() |
Eigene Komponente "vergißt" Eigenschaften...
Wenn ich meine Komponente auf einer Form platziert habe wird KillDuplicates und RealNameEnabled bei jedem öffnen des Projekts auf False gesetzt :roll:
Warum werden die Properties nicht gespeichert :gruebel:
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. |
Re: Eigene Komponente "vergißt" Eigenschaften...
Hai FriFra,
ich kenne mich mit Komponenten nicht so aus ;-) Hast Du mal versucht ![]() |
Re: Eigene Komponente "vergißt" Eigenschaften...
Du mußt KillDuplicates und RealNameEnabled im Konstruktor auf True setzen.
Die Angabe "Default TRUE" beim Property bewirkt nur das die Eigenschaft nicht in der DFM gespeichert wird wenn sie den Wert True besitzt. Das sie den Default-Wert True erhält ist dein Code verantwortlich (Construktor) |
Re: Eigene Komponente "vergißt" Eigenschaften...
Aber ich rufe doch im Constructor "SetDefaults;" auf... In dieser Funktion werden ja alle Eigenschaftswerte gesetzt... Ich kann den Wert ja auch nicht einfach so statisch auf "True" setzen, da er ja im OI auch auf False gesetzt worden sein könnte :roll:
|
Re: Eigene Komponente "vergißt" Eigenschaften...
Zitat:
|
Re: Eigene Komponente "vergißt" Eigenschaften...
Ok, Danke... :oops: jetzt funzt es :lol:
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 00:42 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-2025 by Thomas Breitkreuz