Class TMruMenu (unit MruMenu)

Inherits from

TComponent

Constructors


constructor Create(AOwner: TComponent);

Public declarations


Functions

procedure AddFile(fn : string);


procedure Clear;

So the user can call it after changing all the properties

procedure ConnectToMenu;


destructor Destroy;

This should be unique!

procedure Loaded;

Add the new files to the bottom of the menu

procedure Load_Files(const IniName: string);

Unhook from the Main Menu This is for the weird case where we get destroyed but the menu doesn't.

function MruFilePath: string;

Append them to the parent Menu

procedure Notification(AComponent: TComponent; Operation: TOperation);

This procedure is necessary to properly unhook from the MainMenu.

procedure OnMenuClick(Sender: TObject);

-1 since its 0 indexed

procedure Save_Files(const IniName: string);


procedure UpdateMenu;

Bring it to the top of the list

Properties

property MruGroup : byte


property MruLocation : TMruLocation


property NumFiles : integer


property ParentGroup : byte


property ParentMenu : TMainMenu


property ShowPath : boolean


Events

event OnSelectFile : TSelFileEvent

Published declarations

Variables

Files : TStringList;

Determines if file Path is displayed in the menu

FMainMenu : TMainMenu;

This event fires when the user selects an Mru file on the menu

FMruGroup : byte;

The GroupIndex of the Main Menu Item to append to (usually File = 0

FMruLoc : TMruLocation;

Holds the Mru files

FNumFiles : integer;

Unique Group Num given to Mru Menu Items.

FOnSelFile : TSelFileEvent;


FParGroup : byte;

The Parent Menu used to append the Mru file list

FShowPath : boolean;

Max number of Mru files (default is 4


Constructors


constructor Create(AOwner: TComponent);

Public declarations


Functions


procedure AddFile(fn : string);


procedure Clear;

So the user can call it after changing all the properties


procedure ConnectToMenu;


destructor Destroy;

This should be unique!


procedure Loaded;

Add the new files to the bottom of the menu


procedure Load_Files(const IniName: string);

Unhook from the Main Menu This is for the weird case where we get destroyed but the menu doesn't. It would be dangerous because the Menu OnClick events would be invalid. This section used to crash until I added a Notification handler.


function MruFilePath: string;

Append them to the parent Menu


procedure Notification(AComponent: TComponent; Operation: TOperation);

This procedure is necessary to properly unhook from the MainMenu. It basically handles the message when the MainMenu is destroyed before the MruMenu.


procedure OnMenuClick(Sender: TObject);

-1 since its 0 indexed


procedure Save_Files(const IniName: string);


procedure UpdateMenu;

Bring it to the top of the list


Properties


property MruGroup : byte


property MruLocation : TMruLocation


property NumFiles : integer


property ParentGroup : byte


property ParentMenu : TMainMenu


property ShowPath : boolean


Events


event OnSelectFile : TSelFileEvent

Published declarations


Variables


Files : TStringList;

Determines if file Path is displayed in the menu


FMainMenu : TMainMenu;

This event fires when the user selects an Mru file on the menu


FMruGroup : byte;

The GroupIndex of the Main Menu Item to append to (usually File = 0


FMruLoc : TMruLocation;

Holds the Mru files


FNumFiles : integer;

Unique Group Num given to Mru Menu Items. Needed to delete ONLY the Mru Menu items.


FOnSelFile : TSelFileEvent;


FParGroup : byte;

The Parent Menu used to append the Mru file list


FShowPath : boolean;

Max number of Mru files (default is 4