Zeno Loco Guest
|
Posted: Wed Apr 06, 2005 8:32 am Post subject: Overriding OnClick event for a TMenuItem descendant |
|
|
Hi,
I'm not a "guru" component writer and I'm trying to create a
descendant of a TMenuItem and override the OnClick event.
The problem is that the execution never reach the new OnClick event.
Here is my Code
unit PasswordMenu;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs,
Menus;
type
TPasswordMenuItem = class(TMenuItem)
private
FonClick: TNotifyEvent;
function GetPasswordMenuItem(Index: Integer): TPasswordMenuItem;
protected
protected
public
property Items [Index: Integer]: TPasswordMenuItem read
GetPasswordMenuItem; default;
procedure Click; override;
published
property OnClick;
end;
TPasswordMenu = class(TMainMenu)
private
FItems: TPasswordMenuItem;
function GetItems: TPasswordMenuItem;
public
published
property Items: TPasswordMenuItem read GetItems;
end;
procedure Register;
implementation
procedure TPasswordMenuItem.Click;
begin
inherited Click; // The execution never pass here!
ShowMessage(IntToStr(Tag));
end;
function TPasswordMenuItem.GetPasswordMenuItem(Index: Integer):
TPasswordMenuItem;
begin
Result := TPasswordMenuItem(GetItem (Index));
end;
function TPasswordMenu.GetItems: TPasswordMenuItem;
begin
Result := TPasswordMenuItem(inherited Items);
end;
procedure Register;
begin
RegisterComponents('Standard', [TPasswordMenu]);
end;
end.
Thank you
|
|