troubleshooting Question

Saving / creating menu at runtime

Avatar of KrispyK
KrispyK asked on
Delphi
2 Comments1 Solution493 ViewsLast Modified:
I'm using a TTBXtoolbar in my program.
( www.jrsoftware.org , toolbar2000 );

I would like to be able to load up a file at runtime, and have the contents of a menu be filled from a file.

The menu needs to be able to have all of the normal properties, such as imageindex, caption, subitems, action etc. There can be many subitems per item...which itself can be a subitem...I can't get my head around creating a storage system and loop!

Simple menu :
File               : Edit      : About
 |-Open
 |-Close
 |-Export
 |  |- As TXT
 |  |- as CSV
 |-Exit

Here is a sample for creating a file menu with export and exit :

...
var
item:array[1..99] of TTBXcustomitem;
subitem:array[1..99] of TTBXsubmenuitem;
...
subitem[1]:=TTBXsubmenuitem.create(self);
subitem[1].caption:='&File';
subitem[1].imageindex:=44;
subitem[1].displaymode:=nbdmImageAndText;

item[1]:=TTBXcustomitem.create(self);
item[1].action:=menu_exit;
item[1].caption:='&Exit';
item[1].imageindex:=71;
item[1].displaymode:=nbdmImageAndText;

item[4]:=TTBXcustomitem.create(self);
item[4].caption:='to &TXT file';
item[4].action:=serverlist_export;
item[4].imageindex:=65;
item[4].displaymode:=nbdmImageAndText;

item[5]:=TTBXcustomitem.create(self);
item[5].caption:='to &CSV file';
item[5].action:=serverlist_export;
item[5].imageindex:=65;
item[5].displaymode:=nbdmImageAndText;

subitem[3]:=TTBXsubmenuitem.create(self);
subitem[3].caption:='&Export Serverlist';
subitem[3].imageindex:=65;
subitem[3].displaymode:=nbdmImageAndText;
subitem[3].add(item[5]);
subitem[3].add(item[4]);

subitem[1].add(subitem[3]);
subitem[1].add(item[1]);

toolbar_menu.items.insert(0,subitem[1]);
...

Cheers,
Kris.
ASKER CERTIFIED SOLUTION
Slick812

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros