Board index » cppbuilder » How to create an array of TMenuItem?

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
 
 

Re:How to create an array of TMenuItem?

"didan" < XXXX@XXXXX.COM >wrote:
Quote

Please wrap your lines when you post. Your editor may visually
wrap them for you but you need to enter a hard return at the
end of each line.
Quote
I want to create an array of TMenuItems to hold recent files. Is there any simple way to do it?
How would you propose using these objects? I assume that since
they are TMenuItems that you intend to add them to a menu and
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
 

Re:How to create an array of TMenuItem?

JD wrote:
Quote

"didan" < XXXX@XXXXX.COM >wrote:
>

Please wrap your lines when you post. Your editor may visually
wrap them for you but you need to enter a hard return at the
end of each line.
He's using the Borland web interface for these groups. That thing does
not wrap properly.
--
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}

Re:How to create an array of TMenuItem?

"JD" < XXXX@XXXXX.COM >wrote:
Quote

<snip>
TMenuItem *pItem = new TMenuItem( SomeOtherMenuItem );
pItm->Caption = "SomeCaption";
pItem->OnClick = SomeOnClickEvent;
pItem->GroupIndex = SomeOptionalValue;
pItem->Tag = SomeOtherOptionalValue;
I forgot the most important part:
SomeOtherMenuItem->Add( pItem );
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
 

Re:How to create an array of TMenuItem?

"Rudy Velthuis [TeamB]" < XXXX@XXXXX.COM >wrote:
Quote

He's using the Borland web interface for these groups. That
thing does not wrap properly.
That's what I use and it doesn't wrap at all. That's why the
page says:
Please enter your message text here:(press enter at the
end of each line)
~ JD
 

Re:How to create an array of TMenuItem?

On 27 Jan 2006 12:54:51 -0700, didan wrote:
Quote
I want to create an array of TMenuItems to hold recent files. Is there any simple way to do it?
check out std::vector
--
liz