Thread View: borland.public.delphi.vcl.components.using.general
4 messages
4 total messages
Started by David HAROUCHE
Wed, 02 Jul 2008 19:19
TComponent and TTimer
Author: David HAROUCHE
Date: Wed, 02 Jul 2008 19:19
Date: Wed, 02 Jul 2008 19:19
26 lines
1310 bytes
1310 bytes
What's wrong with that ?
type TMyClass = class(TPaintBox)
....
end;
constructor TMyClass.Create...
begin
inherited
self.mytimer := ttimer.create(owner);
self.mytimer.Enabled := True;
end;
destructor TMyClass.Destroy;
begin
FreeAndNil(self.mytimer);
inherited;
end;
That raises different errors when I close the TForm at design time...
DH
Re: TComponent and TTimer
Author: Marc Rohloff [TeamB]
Date: Wed, 02 Jul 2008 19:52
Date: Wed, 02 Jul 2008 19:52
13 lines
1504 bytes
1504 bytes
On Wed, 2 Jul 2008 21:19:46 +0200, David HAROUCHE wrote: > That raises different errors when I close the TForm at design time... Because you have made the form the owner it has already destroyed your timer for you. I would either set the owner to 'self' and remove the freeandnil or set the owner to nil. -- Marc Rohloff [TeamB] marc -at- marc rohloff -dot- com
Re: TComponent and TTimer
Author: Remy Lebeau (TeamB)
Date: Wed, 02 Jul 2008 20:03
Date: Wed, 02 Jul 2008 20:03
18 lines
1530 bytes
1530 bytes
"David HAROUCHE" <metanil@hotmail.com> wrote in message
news:486bd39f@newsgroups.borland.com...
> self.mytimer := ttimer.create(owner);
You are assigning the wrong owner. Use 'Self' instead:
self.mytimer := ttimer.create(Self);
> That raises different errors when I close the TForm at design time...
Your component's Owner is destroying the TTimer before destroying your
component, and then your component is trying to destroy the TTimer a second
time.
Gambit
Re: TComponent and TTimer
Author: David HAROUCHE
Date: Wed, 02 Jul 2008 21:23
Date: Wed, 02 Jul 2008 21:23
7 lines
999 bytes
999 bytes
Yes Thanks both of you... Solved by setting the Owner at nil... DH
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads