unit SavePanel; { Purpose: Panel that save the caption Author: Vesa Lappalainen Changes: } interface uses SysUtils, Classes, {$ifdef CLX} QGraphics, QControls, QForms, QDialogs, QExtCtrls, {$else} Messages, Graphics, Controls, Forms, Dialogs, ExtCtrls,Gauges, {$endif} kDouble,kinisave; type {----------------------------------------------------------------------------} TSavePanel = class(TPanel) private FIni : TIniSave; FAsString : string; FAfterChange : TNotifyEvent; function GetString: string; procedure SetString(const Value: string); function GetCaption: string; procedure SetCaption(const Value: string); protected public constructor Create(AOwner:TComponent); override; destructor Destroy; override; procedure Loaded; override; published property Ini : TIniSave read FIni write FIni; property AsString : string read GetString write SetString stored false; property Color default $0080ffff; property BevelInner default bvLowered; property BevelOuter default bvRaised; property BevelWidth default 4; property Alignment default taRightJustify; property Caption:string read GetCaption write SetCaption; property AfterChange : TNotifyEvent read FAfterChange write FAfterChange; end; procedure Register; implementation uses KString,IniFiles; procedure Register; begin RegisterComponents('KaveOptions', [TSavePanel]); end; { TSavePanel } constructor TSavePanel.Create(AOwner: TComponent); begin inherited; Color := $0080ffff; FIni := TIniSave.Create(self); Ini.AutoSave := false; Ini.PropName := 'AsString'; BevelInner := bvLowered; BevelOuter := bvRaised; BevelWidth := 4; Alignment := taRightJustify; end; destructor TSavePanel.Destroy; begin FIni.Save; FIni.Free; inherited; end; function TSavePanel.GetCaption: string; begin Result := inherited Caption; end; function TSavePanel.GetString: string; begin Result := Trim(FAsString); end; procedure TSavePanel.Loaded; begin inherited; Ini.Load; end; procedure TSavePanel.SetCaption(const Value: string); begin inherited Caption := Value; FAsString := Value; if ( Ini.AutoSave ) then Ini.SaveCond; if ( Assigned(FAfterChange) ) then FAfterChange(self); end; procedure TSavePanel.SetString(const Value: string); begin Caption := Value; end; end.