//////////////////////////////////////////////////////////////////////////////////////////////
//This part of the code is working:
//to dynamically add submenu items
//Victory x, Victory x, and Victory z, to "Display1":
// step one
// "Display1" was declared earlier using the Tools pallet and Object
inspector
// the declaration of "Display1" looks like this --> TMenuItem
*Display1;
// step two
TMenuItem *Itemx = new TMenuItem( Display1 );
TMenuItem *Itemy = new TMenuItem( Display1 );
TMenuItem *Itemz = new TMenuItem( Display1 );
// step three
Itemx->Caption="Victory x";
Itemy->Caption="Victory y";
Itemz->Caption="Victory z";
// step four
// included for clarity but not needed because Display1 is part of
MainMenu.
// MainMenu is declared as TMainMenu *MainMenu1;
// step five
// menu items added under menu item Display1 as subMenu items
Display1->Add(Itemx);
Display1->Add(Itemy);
Display1->Add(Itemz);
/////////////////////////////////////////////////////////////////////////////////////////
I greatly appreciate any hints.
Thank you,
Jack McDaniel 760 438 9255
void __fastcall TMainMenu1::showmenuClick(TObject *Sender)
{
TMenuItem *Itemx = new TMenuItem( Display1 );
Itemx->OnClick=ItemxOnClickHandler; // assign as the event handler
TMenuItem *Itemy = new TMenuItem( Display1 );
TMenuItem *Itemz = new TMenuItem( Display1 );
Itemx->Caption="Victory x";
Itemy->Caption="Victory y";
Itemz->Caption="Victory z";
Display1->Add(Itemx);
Display1->Add(Itemy);
Display1->Add(Itemz);
}
void __fastcall TMainMenu1::ItemxOnClickHandler(TObject *Sender)
{
//do something
Edit1->Text="itemx clicked";
}
and in the header file obviously add in public
public: // User declarations
void __fastcall ItemxOnClickHandler(TObject *Sender);
--
John Kettle