Board index » cppbuilder » How to create an array of TMenuItem?
didan
![]() CBuilder Developer |
didan
![]() CBuilder Developer |
How to create an array of TMenuItem?2006-01-28 03:54:51 AM cppbuilder38 I want to create an array of TMenuItems to hold recent files. Is there any simple way to do it? Thanks |
JD
![]() CBuilder Developer |
2006-01-28 05:04:42 AM
Re:How to create an array of TMenuItem?
"didan" < XXXX@XXXXX.COM >wrote:
Quote
end of each line. QuoteI want to create an array of TMenuItems to hold recent files. Is there any simple way to do it? if so then you don't need an array at all because TMenuItem decends from TComponent which has an Owner property. Once it's allocated and assigned an Owner, that owner assume responsibility for destroying that object when it is destroyed. This means that you *do not* need to maintain an array of pointers to the allocated objects and if you think that I'm wrong because you might want to delete some of those objects on the fly, you can still do that without the array. I would suggest that you assign the Owner as the next higher menu item. IOW, use the 'parent'TMenuItem as the Owner when you allocate it: TMenuItem *pItem = new TMenuItem( SomeOtherMenuItem ); pItm->Caption = "SomeCaption"; pItem->OnClick = SomeOnClickEvent; pItem->GroupIndex = SomeOptionalValue; pItem->Tag = SomeOtherOptionalValue; ~ JD |
Rudy Velthuis [TeamB]
![]() CBuilder Developer |
2006-01-28 05:07:14 AM
Re:How to create an array of TMenuItem?
JD wrote:
Quote
-- Rudy Velthuis [TeamB] rvelthuis.de/ "I just bought a Mac to help me design the next Cray." -- Seymoure Cray (1925-1996) when was informed that Apple Inc. had recently bought a Cray supercomputer to help them design the next Mac. {smallsort} |
JD
![]() CBuilder Developer |
2006-01-28 05:09:08 AM
Re:How to create an array of TMenuItem?
"JD" < XXXX@XXXXX.COM >wrote:
Quote
where SomeOtherMenuItem is the Owner of pItem. That way, if you delete SomeOtherMenuItem, all of it's sub-Items will automatically be destroyed as well. ~ JD |
JD
![]() CBuilder Developer |
2006-01-28 05:11:06 AM
Re:How to create an array of TMenuItem?
"Rudy Velthuis [TeamB]" < XXXX@XXXXX.COM >wrote:
Quote
Please enter your message text here:(press enter at the end of each line) ~ JD |
Liz Albin
![]() CBuilder Developer |
2006-01-28 05:29:25 AM
Re:How to create an array of TMenuItem?
On 27 Jan 2006 12:54:51 -0700, didan wrote:
QuoteI want to create an array of TMenuItems to hold recent files. Is there any simple way to do it? liz |