 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Nic Guest
|
Posted: Fri Sep 12, 2003 4:17 pm Post subject: How would you do this? |
|
|
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
|
Posted: Sat Sep 13, 2003 11:20 pm Post subject: Re: How would you do this? |
|
|
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
|
Posted: Sun Sep 14, 2003 2:15 pm Post subject: Re: How would you do this? |
|
|
"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 |
|
 |
|
|
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
|
|