TdxBarMRUListItem Class
TdxBarMRUListItem is used to represent a list of most recently used (MRU) items within toolbars.
Declaration
TdxBarMRUListItem = class(
TdxBarListItem
)
Remarks
TdxBarMRUListItem allows you to implement a list of most recently used (MRU) items into your application. This feature can dramatically extend the functionality of your application. For instance, you can use this item to display the list of recently used files in a submenu. This list changes when you close file.
The following procedure adds the closed file to the MRU file list:
procedure TChildForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if MainForm.FileName <> '' then
MainForm.dxBarMRUFiles.AddItem(MainForm.FileName, nil);
Action := caFree;
end;
The following procedure uses the MRU list to open one of the recently used files:
procedure TMainForm.dxBarMRUFilesClick(Sender: TObject);
var
AFileName: String;
begin
AFileName := dxBarMRUFiles.Items[dxBarMRUFiles.ItemIndex];
if FileExists(AFileName) then
with TChildForm.Create(Application) do
begin
FileName := AFileName;
Editor.Lines.LoadFromFile(FileName);
SetModified(False);
end
else
Application.MessageBox(PChar(AFileName+#10#13+'File not found.'),'Open',MB_OK or MB_ICONERROR)
end;
Inheritance
See Also