BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Overriding OnClick event for a TMenuItem descendant

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Writing
View previous topic :: View next topic  
Author Message
Zeno Loco
Guest





PostPosted: Wed Apr 06, 2005 8:32 am    Post subject: Overriding OnClick event for a TMenuItem descendant Reply with quote



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
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Writing All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.