Solved

adding event handler to dynamicaly created MenuItem

Posted on 1997-07-27
1
458 Views
Last Modified: 2010-04-04
Hi,
I am creating MenuItem objects (in delphi 2) dynamicaly in my program. This menu items are subItem of a static menuItem in a mainMenuItem.

The problem is thet i can't find a way to discover which of the dynamically created menu items where selected.
I can't catch the OnClick event...
I did tryied something like thet :
FOnDone: TNotifyEvent; (in TYPE)

property OnDone: TNotifyEvent read FOnDone write FOnDone; (in publish)

but i cant find the place for testing FOnDone value, or creating other function ...

HELPPPPPPPPPPPPPPPP...
0
Comment
Question by:gur
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 4

Accepted Solution

by:
erajoj earned 90 total points
ID: 1340062
Just do like this:

procedure TMainForm.MenuClick(Sender: TObject);
begin
  Caption := 'Menu Clicked';
end;
  ...
  ...
var
  NewMenuItem : TMenuItem;
  ...
  ...
  NewMenuItem := TMenuItem.Create(MyMenu);
  with NewMenuItem do begin
    NewMenuItem.Caption := 'EventConnected menu item';
    NewMenuItem.OnClick := MenuClick; // Here's the "magic"!
    MyMenu.Add(NewMenuItem);          // Put it last
  end;
  ...
  ...

Easier than you thought, huh?

/// John

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question