home *** CD-ROM | disk | FTP | other *** search
- unit RollbackForm;
- {------------------------------------------------------------------------------}
- { RollbackForm.pas: List of file dates available in backup files. }
- { }
- { Part of the Delphi 4 Sample application for the Xceed Backup Library }
- { Copyright (C) 1999 - Xceed Software Inc. }
- {------------------------------------------------------------------------------}
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- StdCtrls, OleCtrls, XceedBackupLib_TLB;
-
- type
- TfrmRollback = class(TForm)
- Label1: TLabel;
- lstFiles: TListBox;
- chkLatest: TCheckBox;
- btRestore: TButton;
- btCancel: TButton;
- procedure chkLatestClick(Sender: TObject);
- procedure btRestoreClick(Sender: TObject);
- procedure btCancelClick(Sender: TObject);
- procedure BrowsingCatalogEntry(Sender: TObject;
- const sFilename: WideString; lSize: Integer; xAttributes: TOleEnum;
- dtLastModified, dtLastAccessed, dtCreated: TDateTime;
- lDiskNumber: Integer; const sMediaLabel: WideString);
- procedure lstFilesClick(Sender: TObject);
- procedure lstFilesDblClick(Sender: TObject);
- private
- { Private declarations }
- procedure UpdateRestoreState;
- public
- { Public declarations }
- { We voluntarily hide the default ShowModal method }
- function ShowModal( xMain : TXceedBackup; xFiles : TFileSelection ) : integer;
- end;
-
- var
- frmRollback: TfrmRollback;
-
- implementation
-
- {$R *.DFM}
-
- {------------------------------------------------------------------------------}
- { ShowModal: Our version of this virtual method. We fill the list of available }
- { file dates before showing the form modally. }
- {------------------------------------------------------------------------------}
- function TfrmRollback.ShowModal( xMain : TXceedBackup; xFiles : TFileSelection ) : integer;
- begin
- lstFiles.Items.Clear;
-
- { For our Rollback form, we wrote a handler for the XceedBackup control's
- OnBrowsingCatalogEntry event that adds browsed entries to our listbox.
- We assign the handler now (instead of using the object inspector) so that
- the main Sample form is not notified about catalog entries being listed. }
- xMain.OnBrowsingCatalogEntry := BrowsingCatalogEntry;
-
- { Browse the catalogs. The 'xFiles' TFileSelection control contains the
- filename of the text file we are interested in. }
- xMain.BrowseCatalogs( xFiles.ControlInterface, 'Delphi Sample' );
-
- { Unnasign our BrowsingCatalogEntry handler }
- xMain.OnBrowsingCatalogEntry := nil;
-
- UpdateRestoreState;
- Result := inherited ShowModal;
-
- if Result = 1 then
- begin
- if chkLatest.Checked then { To restore latest file, set date to 9999/12/31 }
- xFiles.MaxDate := EncodeDate( 9999, 12, 31 )
- else { Otherwise, set the date to the listbox's selected date }
- xFiles.MaxDate := StrToDateTime( lstFiles.Items.Strings[ lstFiles.ItemIndex ] );
- end;
- end;
-
- {------------------------------------------------------------------------------}
- { BrowsingCatalogEntry event: This is the event we manually assigned above. }
- { It is triggered for each entry found in a catalog. We add the entry to }
- { the listbox }
- {------------------------------------------------------------------------------}
- procedure TfrmRollback.BrowsingCatalogEntry(Sender: TObject;
- const sFilename: WideString; lSize: Integer; xAttributes: TOleEnum;
- dtLastModified, dtLastAccessed, dtCreated: TDateTime;
- lDiskNumber: Integer; const sMediaLabel: WideString);
- begin
- lstFiles.Items.Add( DateTimeToStr( dtLastModified ) );
- end;
-
- procedure TfrmRollback.UpdateRestoreState;
- begin
- btRestore.Enabled := chkLatest.Checked or ( lstFiles.ItemIndex >= 0 );
- end;
-
- procedure TfrmRollback.chkLatestClick(Sender: TObject);
- begin
- UpdateRestoreState;
- end;
-
- procedure TfrmRollback.btRestoreClick(Sender: TObject);
- begin
- ModalResult := mrOK;
- end;
-
- procedure TfrmRollback.btCancelClick(Sender: TObject);
- begin
- ModalResult := mrCancel;
- end;
-
- procedure TfrmRollback.lstFilesClick(Sender: TObject);
- begin
- UpdateRestoreState;
- end;
-
- procedure TfrmRollback.lstFilesDblClick(Sender: TObject);
- begin
- UpdateRestoreState;
- if btRestore.Enabled then
- ModalResult := mrOK;
- end;
-
- end.
-