Solved

adding event handler to dynamicaly created MenuItem

Posted on 1997-07-27
1
460 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

Industry Leaders: 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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month6 days, 19 hours left to enroll

622 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