Google Mail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
ActiveForm OnCreate and OnDestroy
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Follow-up To:
Add Cc | Add Follow-up to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers that you hear
 
Tony Mountifield  
View profile   Translate to Translated (View Original)
 More options 15 Mar 2005, 12:11
Newsgroups: borland.public.delphi.com.activex.writing
From: "Tony Mountifield" <t...@softins.co.uk>
Date: Tue, 15 Mar 2005 12:11:19 -0000
Local: Tues 15 Mar 2005 12:11
Subject: ActiveForm OnCreate and OnDestroy
I am writing an Active Form in D6, and found that if it created an
ActiveFormDestroy handler for the form's OnDestroy event, it never got
called. The OnCreate event was fired without any problems.

After some investigation, I found the following:
1. OnCreate is called before the event sink is set up. That is why it works
fine.
2. When the event sink is set up, the events OnActivate, OnClick, OnCreate,
OnDblClick, OnDeactivate, OnDestroy, OnKeyPress and OnPaint all get
overwritten in TActiveFormX.Initialize. I don't understand event sinks (I
just want to write a form to run in a browser), so I don't know if the
original values were supposed to have been copied into FEvents.
3. In any case, when I close the browser, the TActiveFormX.DestroyEvent
procedure gets called, only to find FEvents is nil.
4. The BeforeDestruction procedure finds that the OnDestroy event is nil.

I found two possible ways to overcome this and ensure my OnDestroy handler
gets called, and I wonder which is the more correct:
1. Comment out the OnCreate and OnDestroy assignments in
TActiveFormX.Initialize. The OnCreate handler has already been called
anyway, and by the time we want the OnDestroy event, we are on our way out
anyway. Is there a reason to sink OnCreate and OnDestroy?
2. Override TActiveFormX.BeforeDestruction and re-assign OnDestroy :=
ActiveFormDestroy; before calling inherited BeforeDestruction. This ensures
that the inherited BeforeDestruction procedure finds and OnDestroy handler
to execute.

I noticed that the first method happens earlier in the cleanup process (it
happens even before BeforeDestruction is called), but I've no idea how to
decide which method to use.

Any advice would be very much appreciated.

Tony
--
Tony Mountifield
Work: t...@softins.co.uk - http://www.softins.co.uk
Play: t...@mountifield.org - http://tony.mountifield.org


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Brian Cook  
View profile   Translate to Translated (View Original)
 More options 15 Mar 2005, 20:58
Newsgroups: borland.public.delphi.com.activex.writing
From: Brian Cook <bcook@rowdydogsoftware[REMOVE].com>
Date: Tue, 15 Mar 2005 14:58:54 -0600
Local: Tues 15 Mar 2005 20:58
Subject: Re: ActiveForm OnCreate and OnDestroy
In article <4236d...@newsgroups.borland.com>, t...@softins.co.uk says...

Just override "Destroy" and don't even bother with "OnDestroy".

- Brian


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google