BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How would you do this?

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (IDE)
View previous topic :: View next topic  
Author Message
Nic
Guest





PostPosted: Fri Sep 12, 2003 4:17 pm    Post subject: How would you do this? Reply with quote



On Borland C++ Builder 6...

I have a list of nodes. Each node contains one number, [0-9]. I want
to show the user the contents of the list. In a console application,
I just cout the value in each node and that's it.

Now in the GUI, I need to display the contents of the list. I have a
picture (.bmp) that represents each possible value.

I do not want to simply draw each picture side by side in an image and
show that, since the user must be able to right-click on each picture
separately and do something with it.

The problem I faced up to now is:
- I do not know how many nodes I have in the list until the user's
done some action so I cannot just pile up TImage objects and use
these. But then how do I create new objects at runtime? Aren't they
deallocated when the print list function completes?

So how to dynamically create objects and associate events and submenus
to these objects?

I hope this is clear enough, Nic.
Back to top
pem3v78
Guest





PostPosted: Sat Sep 13, 2003 11:20 pm    Post subject: Re: How would you do this? Reply with quote



Hello,

I'll be brief coz you didn't specify the problem in details.

I suppose You know how to use containers, huh ?

1. Create a container (vector from stl is a good example) to hold pointers
to newly allocated components.
2. When You need more components do them like that (example for TMenuItem
which shows in submenu)
TMenuItem *tmi = new TMenuItem(Regiony); //Regiony is a
popup menu - an owner component
tmi->OnClick = Region1Click; //
When user clicks the menu fire up Region1Click method
(if you got other component eg. Button you have to specyfy the "Parent" -
where the component will be shown, eg.
button->Parent = Form1;
3. Add pointer (tmi) to vector.
4. When Your done with the component use delete operator to delete it from
heap and remove the pointer from collection.

Simple enough ?

Cheers,
Mike

"Nic" <nicflatterie (AT) yahoo (DOT) com> wrote

Quote:
On Borland C++ Builder 6...

I have a list of nodes. Each node contains one number, [0-9]. I want
to show the user the contents of the list. In a console application,
I just cout the value in each node and that's it.

Now in the GUI, I need to display the contents of the list. I have a
picture (.bmp) that represents each possible value.

I do not want to simply draw each picture side by side in an image and
show that, since the user must be able to right-click on each picture
separately and do something with it.

The problem I faced up to now is:
- I do not know how many nodes I have in the list until the user's
done some action so I cannot just pile up TImage objects and use
these. But then how do I create new objects at runtime? Aren't they
deallocated when the print list function completes?

So how to dynamically create objects and associate events and submenus
to these objects?

I hope this is clear enough, Nic.



Back to top
Nic
Guest





PostPosted: Sun Sep 14, 2003 2:15 pm    Post subject: Re: How would you do this? Reply with quote



"pem3v78" <pem3v78 (AT) wp (DOT) pl> wrote

Quote:
Hello,

I'll be brief coz you didn't specify the problem in details.

I suppose You know how to use containers, huh ?

1. Create a container (vector from stl is a good example) to hold pointers
to newly allocated components.
2. When You need more components do them like that (example for TMenuItem
which shows in submenu)
TMenuItem *tmi = new TMenuItem(Regiony); //Regiony is a
popup menu - an owner component
tmi->OnClick = Region1Click; //
When user clicks the menu fire up Region1Click method
(if you got other component eg. Button you have to specyfy the "Parent" -
where the component will be shown, eg.
button->Parent = Form1;
3. Add pointer (tmi) to vector.
4. When Your done with the component use delete operator to delete it from
heap and remove the pointer from collection.

Simple enough ?

Cheers,
Mike


No I did not know about containers. I will have a look at it, thanks!
Strange, I thought my question was clear enough, but from your answer
I see you understood what I needed anyway.
Nic.

Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (IDE) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.