Board index » cppbuilder » Finding a TMenuItem

Finding a TMenuItem


2005-01-27 02:13:30 AM
cppbuilder95
Hello Everyone,
I have a TMainMenu on Form1, which contains several submenus, which
contain lots of TMenuItems. I am looking for a good way to get a
pointer to one of the TMenuItems.
Currently I have a way to do it, but it's probably not the correct method.
This is what I currently do:
/******/
TMenuItem *mItem = MainMenu1->FindItem( ShortCut('1', TShiftState()
<< ssCtrl), fkShortCut );
/******/
Is there a better way (one that wouldn't require a ShortCut)?
Thanks for your help,
Mark
 
 

Re:Finding a TMenuItem

Mark Mussetter < XXXX@XXXXX.COM >wrote:
Quote

[...] I am looking for a good way to get a pointer to one of
the TMenuItems. [...] Is there a better way (one that wouldn't
require a ShortCut)?
You have 2 choices. One is to iterate all of the MenuItem's
yourself. The other is to allocate and insert the item at
runtime.
~ JD
 

Re:Finding a TMenuItem

Mark Mussetter wrote:
Quote
Is there a better way (one that wouldn't require a ShortCut)?
When I had to do that I just iterated the menu 'tree' until I found
what I wanted. Then again that was a long time ago so there may well be
a better solution.
In case you don't know how to iterate the tree you just use each
TMenuItem's 'Items' property :)
--
Andrue Cope [TeamB]
[Bicester, Uk]
info.borland.com/newsgroups/guide.html
 

{smallsort}

Re:Finding a TMenuItem

Andrue Cope [TeamB] wrote:
Quote
Mark Mussetter wrote:


>Is there a better way (one that wouldn't require a ShortCut)?


When I had to do that I just iterated the menu 'tree' until I found
what I wanted. Then again that was a long time ago so there may well be
a better solution.

In case you don't know how to iterate the tree you just use each
TMenuItem's 'Items' property :)

Thanks for the help guys