Link to home
Start Free TrialLog in
Avatar of ralph78
ralph78Flag for France

asked on

easy

how to get acces on a run time created object event (with the 'create' procedure)?
for an example, the TmenuItem component

var item:TMenuItem;
begin
item:=TmenuItem.create(nil);
item.caption='test';
form1.new1.add(item);

new1 is a menuitem created at design time, and i want to get the testclick event.

thanks!
ASKER CERTIFIED SOLUTION
Avatar of inthe
inthe

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of inthe
inthe

whoops typo should read:

{public}
Procedure ClickItem(Sender:TObject);

If I understand you, you want to get the OnClick event for the TMenuItem you just created (and called 'test'), through the New1 menu item?

If so, you can do it like this:

for I := 0 to form1.new1.count - 1 do
  if form1.new1.items[i].Caption = 'test' then
    form1.new1.items[i].OnClick := DoTheClick;

Cheers,

Raymond.