Board index » delphi » Dynamically add menu items - how to get OnClick?

Dynamically add menu items - how to get OnClick?

Hello,
I can add menu items dynamically, which is great.  But now I need to
be notified when one of the new items is chosen.  Do I set a callback
or what?

Paul
Paul Foglia     -- p...@world.std.com

"In nature there are no rewards or punishments; there are consequences".
-- Horace Annesley Vachell, 'The Force of Clay'

 

Re:Dynamically add menu items - how to get OnClick?


On Tue, 17 Sep 1996 22:33:51 GMT, Paul.Fog...@fmr.com (Paul Foglia)
you smacked the keyboard repeatedly to write:

Quote
>Hello,
>I can add menu items dynamically, which is great.  But now I need to
>be notified when one of the new items is chosen.  Do I set a callback
>or what?

>Paul
>Paul Foglia     -- p...@world.std.com

>"In nature there are no rewards or punishments; there are consequences".
>-- Horace Annesley Vachell, 'The Force of Clay'

use this:

        in your form that has the menu add:

        TForm1 = class(TForm)
                private
                        procedure MenuClick(Sender: TObject);
        end;

        procedure TForm1.MenuClick(Sender: TObject);
        begin
                {This is where you handle the menu click}
        end;

then when you create the menu item, you add:

        MyMenuItem := TMenuItem.Create(Form1);
        MyMenuItem.OnClick := Form1.MenuClick;

Brien King
bk...@primenet.com

Other Threads