| View previous topic :: View next topic |
| Author |
Message |
David Ayre Guest
|
Posted: Wed Dec 24, 2003 2:26 pm Post subject: new and delete a component |
|
|
I am trying to use a component (TRecorder) which I have placed
on the form. It works OK the first time I run it, but crashes
on a second entry. There are obviously parameters in the
component that need reseting but I don't know what they are.
How do I create the component at runtime so that it is available
globally and then delete it when it has done it's work?
I know this is probably very fundamental but I can't work it out
using trial and error.
Thanks for any help.
Cheers,
David
N.B. Happy Christmas
|
|
| Back to top |
|
 |
David Ayre Guest
|
Posted: Wed Dec 24, 2003 3:15 pm Post subject: Re: new and delete a component |
|
|
Hi Hans,
It is a third party component. I think I know how to create it
at run time. I tried to create it in one routine but I also
need to access it in another routine. These are all in the
same form.
Cheers,
David
Hans Galema <dontusethis (AT) dontusethis (DOT) nl> wrote:
| Quote: | David Ayre wrote:
I am trying to use a component (TRecorder)
Where does that come from ? I do not find it in bcb3 nor bcb5.
How do I create the component at runtime so that it is available
globally
Is that one question ? Can I conclude that you know how to
create it dinamic, and that the global aspect is the only
problem ?
Why global ? More Forms or units that interfere with the recorder ?
Hans.
|
|
|
| Back to top |
|
 |
David Ayre Guest
|
Posted: Wed Dec 24, 2003 3:28 pm Post subject: Re: new and delete a component |
|
|
Thanks Hans,
That gives me something to be going on with.
Happy Christmas to you.
Cheers,
David
Hans Galema <dontusethis (AT) dontusethis (DOT) nl> wrote:
| Quote: | David Ayre wrote:
It is a third party component. I think I know how to create it
at run time.
You could have give the code here already!
I tried to create it in one routine but I also
need to access it in another routine. These are all in the
same form.
You first need to declare in your forms class definition a private or
public pointer.
//in Unit.h
private:
TRecorder Recorder;
//Unit.cpp
then in one classmemberfunction you can create one with:
Recorder = new TRecorder;
// or
// Recorder = new TRecorder ( this ); // look at the documentation
and delete it in another with:
delete Recorder.
Meanwhile you can use it in other classmemberfuctions likeL:
Recorder->Start();
and so on.
Hans.
|
|
|
| Back to top |
|
 |
Hans Galema Guest
|
Posted: Wed Dec 24, 2003 3:51 pm Post subject: Re: new and delete a component |
|
|
David Ayre wrote:
| Quote: | I am trying to use a component (TRecorder)
|
Where does that come from ? I do not find it in bcb3 nor bcb5.
| Quote: | How do I create the component at runtime so that it is available
globally
|
Is that one question ? Can I conclude that you know how to
create it dinamic, and that the global aspect is the only
problem ?
Why global ? More Forms or units that interfere with the recorder ?
Hans.
|
|
| Back to top |
|
 |
Hans Galema Guest
|
Posted: Wed Dec 24, 2003 4:29 pm Post subject: Re: new and delete a component |
|
|
David Ayre wrote:
| Quote: | It is a third party component. I think I know how to create it
at run time.
|
You could have give the code here already!
| Quote: | I tried to create it in one routine but I also
need to access it in another routine. These are all in the
same form.
|
You first need to declare in your forms class definition a private or
public pointer.
//in Unit.h
private:
TRecorder Recorder;
//Unit.cpp
then in one classmemberfunction you can create one with:
Recorder = new TRecorder;
// or
// Recorder = new TRecorder ( this ); // look at the documentation
and delete it in another with:
delete Recorder.
Meanwhile you can use it in other classmemberfuctions likeL:
Recorder->Start();
and so on.
Hans.
|
|
| Back to top |
|
 |
David Ayre Guest
|
Posted: Wed Dec 24, 2003 6:33 pm Post subject: Re: new and delete a component |
|
|
| Quote: | You first need to declare in your forms class definition a private or
public pointer.
//in Unit.h
private:
TRecorder Recorder;
|
I realised that this should have been
TRecorder *Recorder; So I used that;
| Quote: |
//Unit.cpp
then in one classmemberfunction you can create one with:>> // Recorder = new TRecorder ( this );
I used this and it worked fine. |
Thanks for your help.
Cheers,
David
|
|
| Back to top |
|
 |
Hans Galema Guest
|
Posted: Wed Dec 24, 2003 7:49 pm Post subject: Re: new and delete a component |
|
|
David Ayre wrote:
| Quote: | I realised that this should have been
TRecorder *Recorder; So I used that;
|
Yes, indeed. My mistake. Sorry for the inconvenience.
Hans.
|
|
| Back to top |
|
 |
|