FileManager
v1.00
© 2007, Priyatna
Bandung - Indonesia
http://www.priyatna.org/
mailto:me@priyatna.org
Introduction
License
Installation
Methods
Properties
Events
Contacts
Version: 1.00
Release Date: May 26th, 2007
Introduction
FileManager is a Delphi component that serves as a file manager for your application.
Imagine a simple text editor. If the edited text is dirty (modified), prior
to close or create a new text editor, it must ask user a filename in which it
can save the text, or it saves without asking the filename if the text is saved
before. There's also a sub menu (usually under File menu) that contains
most recent files (MRU), that if user click on it, will launch the file. Of
course it will ask to save current edited text prior to opening the file. This
seems to be a simple task, but believe me, it can be confusing.
This component can handle all the above tasks seamlessly. It will save you
lot of time, and is very easy to use. It is used extensively in all my programs,
and so far so good.
License
This library is released under Mozilla Public License. You can use it in your
freeware, shareware or commercial softwares. You can send your modification
to me, and if I decide to include it in the main distribution, I will add your
name as a contributor. You can read full licensing information here.
Installation
There is no special process to install it on Delphi. Just open FileManagersD7.dpk
on Delphi IDE and press Install button. I use Delphi 7. If you use another Delphi
version, you may have to make some minor changes.
The component will appear in priyatna.org tab.
Methods
There are some main methods of the component:
- procedure New;
Tells the component that a newdocument is being created. Usually you call
this method in File > New event handler of the main menu.
- procedure Open;
Instructs the component to open a new file. If the currently edited file is
modified, the component will ask user whether the file should be saved or
not, ask a filename if necessary, and then ask a filename to be opened. Usually
you call this method in File > Open event handler of the main menu.
- procedure Save;
Instructs the component to save the currently edited document. If necessary,
it will ask the filename to the user. Usually you call this method in File
> Save event handler of the main menu.
- procedure SaveAs;
Instructs the component to save the currently edited document to a new file.
Usually you call this method in File > Save as event handler of
the main menu.
- function Close: TCloseAction;
Tells the component that the application is about to close. It will ask the
user whether the currently edited document should be saved or not, ask filename
when necessary, etc. The user can cancel the closing. Usually you call this
method in FormClose event handler of the main form. Feed the Action
variable with the result of this function, so if the user cancels the closing,
the form doesn't close.
- procedure LoadMRUFromIni(Ini: TIniFile; Section: string = MRUSection);
Loads most recent files from an INI file. Usually you call this method in
FormCreate event handler of the main form. The MRU list is maintained
automatically by the component.
- procedure SaveMRUToIni(Ini: TIniFile; Section: string = MRUSection);
Saves most recent files to an INI file. Usually you call this method in FormDestroy
event handler of the main form. The MRU list is maintained automatically by
the component.
- procedure LoadMRUFromFile(FileName: TFileName);
Loads most recent files from an a file. Usually you call this method in FormCreate
event handler of the main form. The MRU list is maintained automatically by
the component.
- procedure SaveMRUToFile(FileName: TFileName);
Saves most recent files to a file. Usually you call this method in FormDestroy
event handler of the main form. The MRU list is maintained automatically by
the component.
- procedure ShowMRUList(Menu: TMenuItem);
Shows most recent files under the specified sub menu. Usually you call this
method in FormCreate event handler of the main form.
- procedure ManualOpen(AFileName: TFileName);
Instructs the component to open a specified file, without showing the open
dialog. It is useful when you want to open a file supplied by command line.
- procedure ManualSave(AFileName: TFileName);
Instructs the component to save the currently edited file to a specified file
without showing the save dialog.
Properties
There are some main properties of the component:
- property FileName: TFileName;
Is a read-only property that specifies the currently opened filename.
- property Modified: Boolean;
Specifies whether the current document is modified or not. You set this property
to True to tell the component that the file is dirty, so it knows what action
to do.
- property MaxMRUCount: Integer;
Specifies the maximum count of the most recent files maintained by the component.
- property OpenDialog: TOpenDialog;
Specifies the open dialog to use by the component. With this mechanism, you
can customize the open dialog, for example, setting an appropriate Filter
property.
- property SaveDialog: TSaveDialog;
Specifies the save dialog to use by the component. With this mechanism, you
can customize the save dialog, for example, setting an appropriate Filter
property.
Events
There are some main properties of the component:
- property OnChangeFile: TNotifyEvent;
Fired everytime the filename changes.
- property OnModified: TNotifyEvent;
Fired everytime the currently edited document is modified.
- property OnNew: TOnNewEvent;
function (Sender: TObject): Boolean of object;
Fired when the component needs to create a new document. Give a True
result to tell the component that the new document is successfully created.
- property OnOpen: TOnOpenSaveEvent;
TOnOpenSaveEvent = function (Sender: TObject; FileName: TFileName): Boolean
of object;
Fired when the component needs to open a file specified by FileName
parameter. Give a True result to tell the component that the document
is successfully opened.
- property OnSave: TOnOpenSaveEvent;
TOnOpenSaveEvent = function (Sender: TObject; FileName: TFileName): Boolean
of object;
Fired when the component needs to save a file specified by FileName
parameter. Give a True result to tell the component that the document
is successfully saved.
Contacts
Don't hesitate to report any bug or whish to me:
Priyatna
Bandung - Indonesia
http://www.priyatna.org/
mailto:me@priyatna.org