Article View: comp.lang.pascal.delphi.misc
Article #65Re: How to dynamically add a menuitem in run-time ?
From: Niklas Lagergren
Date: Sat, 17 Apr 1999 00:00
Date: Sat, 17 Apr 1999 00:00
60 lines
3049 bytes
3049 bytes
This is a procedure that I ripped from on of my programs that does it:
procedure InitPlugin(ParentMenu: TMainMenu);
var
i: TMenuItem;
begin
// Create new menu item
i := NewItem('Plugin &1', // Caption
scNone, // Shortcut
False, // Checkmark
True, // Enabled
Holder.ClickHandler, // Event handler
0, // Help context ID
'Plugin_1'); // Name
ParentMenu.Items[0].Add(i);
end;
Lookup NewItem in the help if you don't understand it...
Regards,
Lani
"Chow Hoi Ka, Eric" skrev:
> Hello,
>
> How to dynamically add a menuitem in run-time ?
> And if it is possible, how to dynamically add the action-event(Click)
> for it ?
>
> For example,
> The following is the Menu structure :
>
> [Edit]
> Undo
> Cut
> other_Menu_Item
>
> My main question is that how can I dynamically add the other_menu_item
> in thge Edit menu in run-time and with the Click Event?
> If I don't know how many "other_Menu_Item" will be added in the design
> time, how to implement this with Click Event?
>
> Would you please to give me a simple example about this ????
>
> Best regards,
> Eric
>
> --
> _ _
> / ) |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| ( \
> / / | | \ \
> _( /_ | _ Chow Hoi Ka, Eric _ | _) )_
> (((\ \> |/ ) ( \| </ /)))
> (\\\\ \_/ / E-Mail : d951686@sftw.umac.mo \ \_/ ////)
> \ / \ /
> \ _/ http://www.sftw.umac.mo/~d951686/ \_ /
> / / |____________________________________________| \ \
> / / \ \
Technical Details
Message-ID:
<371864A7.14CD5263@swipnet.se>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<371863FB.28DA658E@sftw.umac.mo>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1043cf,8c4b696a74ad7796 X-Google-Attributes: gid1043cf,public X-Google-Thread: 10baee,8c4b696a74ad7796 X-Google-Attributes: gid10baee,public X-Google-Thread: fd817,8c4b696a74ad7796 X-Google-Attributes: gidfd817,public X-Google-Thread: 115d96,8c4b696a74ad7796 X-Google-Attributes: gid115d96,public From: Niklas Lagergren <lani@swipnet.se> Subject: Re: How to dynamically add a menuitem in run-time ? Date: 1999/04/17 Message-ID: <371864A7.14CD5263@swipnet.se> X-Deja-AN: 467549981 Content-Transfer-Encoding: 7bit References: <371863FB.28DA658E@sftw.umac.mo> X-Accept-Language: sv Content-Type: text/plain; charset=us-ascii X-Complaints-To: news-abuse@swip.net X-Trace: nntpserver.swip.net 924345609 130.244.72.59 (Sat, 17 Apr 1999 12:40:09 MET DST) Organization: A Customer of Tele2 MIME-Version: 1.0 NNTP-Posting-Date: Sat, 17 Apr 1999 12:40:09 MET DST Newsgroups: comp.lang.pascal.delphi.misc,alt.comp.lang.borland-delphi,borland.public.delphi.database,borland.public.delphi.objectpascal