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 

new and delete a component

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage)
View previous topic :: View next topic  
Author Message
David Ayre
Guest





PostPosted: Wed Dec 24, 2003 2:26 pm    Post subject: new and delete a component Reply with quote




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





PostPosted: Wed Dec 24, 2003 3:15 pm    Post subject: Re: new and delete a component Reply with quote




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





PostPosted: Wed Dec 24, 2003 3:28 pm    Post subject: Re: new and delete a component Reply with quote




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





PostPosted: Wed Dec 24, 2003 3:51 pm    Post subject: Re: new and delete a component Reply with quote

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





PostPosted: Wed Dec 24, 2003 4:29 pm    Post subject: Re: new and delete a component Reply with quote

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





PostPosted: Wed Dec 24, 2003 6:33 pm    Post subject: Re: new and delete a component Reply with quote


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





PostPosted: Wed Dec 24, 2003 7:49 pm    Post subject: Re: new and delete a component Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage) 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.