Link to home
Start Free TrialLog in
Avatar of KrispyK
KrispyK

asked on

Saving / creating menu at runtime

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
Avatar of Member_2_248744
Member_2_248744
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of KrispyK
KrispyK

ASKER

Thanks mate. Didn't know about the writecomponent method!