Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to copy all settings from a MenuItem made at designtime to a MenuItem create Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
23-Oct-02
Category
VCL-Menu
Language
Delphi 2.x
Views
114
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Jonas Bilinkevicius

I am trying to make it possible for my program to create new MenuItems at runtime. 
I want to copy the settings from a MenuItem made at designtime to the new 
MenuItems. All the properties and event handlers.

Answer:
1   
2   procedure CopyMenuRaw(const Source, MenuTest: TMenuItem);
3   begin
4     MenuTest.Caption := Source.Caption;
5     MenuTest.Checked := Source.Checked;
6     MenuTest.default := Source.default;
7     MenuTest.Enabled := Source.Enabled;
8     MenuTest.GroupIndex := Source.GroupIndex;
9     MenuTest.HelpContext := Source.HelpContext;
10    MenuTest.Hint := Source.Hint;
11    MenuTest.ImageIndex := Source.ImageIndex;
12    MenuTest.Name := Source.Name;
13    MenuTest.RadioItem := Source.RadioItem;
14    MenuTest.Tag := Source.Tag;
15    MenuTest.Visible := Source.Visible;
16    MenuTest.OnClick := Source.OnClick;
17    MenuTest.OnDrawItem := Source.OnDrawItem;
18    MenuTest.OnMeasureItem := Source.OnMeasureItem;
19  end;
20  
21  procedure CopyMenuItem(var Source, MenuTest: TMenuItem);
22  begin
23    MenuTest := TMenuItem.Create(nil);
24    CopyMenuRaw(Source, MenuTest);
25  end;
26  
27  //Used like this:
28  
29  CopyMenuItem(WholeScreen1, MenuTest);


Where WholeScreen1 is an existing TMenuItem and MenuTest is TMenuItem that is 
defined in
your Var section.

			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC