
TTBMRUList
Properties | Methods
Description:
This component holds items for a Most Recently Used list. It is intended to be linked to a TTBMRUListItem item on a menu via its MRUList property.
Key Properties:
- property AddFullPath: Boolean default True;
When True, items added to the list via the Add method will be expanded into fully qualified pathnames. If your MRU list doesn't contain filenames, this property should be changed to False.
- property HidePathExtension: Boolean default True;
When True, pathnames will be hidden when the items are displayed, as well as file extensions if Explorer is configured to "hide file extensions for known file types." If your MRU list doesn't contain filenames, this property should be changed to False.
- property Items: TStrings;
The items in the MRU list. You can read and directly manipulate the MRU list items via this property.
- property MaxItems: Integer default 4;
The maximum number of items that the list may contain. When MaxItems is exceeded, one or more items are deleted from the end of the list.
- property Prefix: string;
The string prefixed to the names of values read and written by the LoadFrom* and SaveTo* methods. The default is "MRU", making the name of the first value "MRU0".
Key Methods:
- procedure Add(const Filename: string);
Adds a new filename to the top of the MRU list. If the specified filename already exists in the MRU list, it will be moved to the top.
The Add method is the preferred way of adding new items to the MRU list.
- procedure LoadFromIni(Ini: TCustomIniFile; const Section: string);
Loads the MRU items from a TIniFile component or other TCustomIniFile descendant. Section specifies the section name to read from.
Usage example:
procedure TForm1.FormCreate(Sender: TObject);
var
Ini: TIniFile;
begin
Ini := TIniFile.Create('MyProgram.ini');
try
MRUList.LoadFromIni(Ini, 'MRUList');
finally
Ini.Free;
end;
end;
- procedure LoadFromRegIni(Ini: TRegIniFile; const Section: string);
Loads the MRU items from a TRegIniFile component. Section specifies the section name to read from.
Usage example:
procedure TForm1.FormCreate(Sender: TObject);
var
Ini: TRegIniFile;
begin
Ini := TRegIniFile.Create('Software\My Company\My Program');
try
MRUList.LoadFromRegIni(Ini, 'MRUList');
finally
Ini.Free;
end;
end;
- procedure Remove(const Filename: string);
Removes the specified filename from the MRU list if it exists.
- procedure SaveToIni(Ini: TCustomIniFile; const Section: string);
Saves the MRU items to a TIniFile component or other TCustomIniFile descendant. Section specifies the section name to save to.
Usage example:
procedure TForm1.FormDestroy(Sender: TObject);
var
Ini: TIniFile;
begin
Ini := TIniFile.Create('MyProgram.ini');
try
MRUList.SaveToIni(Ini, 'MRUList');
finally
Ini.Free;
end;
end;
- procedure SaveToRegIni(Ini: TRegIniFile; const Section: string);
Saves the MRU items to a TRegIniFile component. Section specifies the section name to save to.
Usage example:
procedure TForm1.FormDestroy(Sender: TObject);
var
Ini: TRegIniFile;
begin
Ini := TRegIniFile.Create('Software\My Company\My Program');
try
MRUList.SaveToRegIni(Ini, 'MRUList');
finally
Ini.Free;
end;
end;