Board index » delphi » ActiveX-Ctrl termination during "Loaded" processing

ActiveX-Ctrl termination during "Loaded" processing

 For some reasons, I may need to stop my application very early.

 For instance, I want to completly exit my app. while processing the
"loaded" event of a non-visual component on my main form.

 If I try simply to quit it with "Application.Terminate", the processing
continue until the "Application.Run" (even with a
"Application.ProcessMessages" ). Thus I can have some (lenghty) TDatabase
initialization or even a splash-screen showing !

 Therefore, I use a "halt" in such case, which is quite brutal but
effective.

Effective, except for the ActiveX controls, which yeld me Runtime error 216
in TOle.Destroy.

 I tried a few things. The best thing I found is to explicitly destroy the
activeX controls by freeing them. This gives me something such as :
With Owner do
  for i:=ComponentCount-1 downto 0 do
    if (Components[i] is TOLEControl) then
      components[i].free;

 Is there a better way to stop the program dead in its track while not
having complains from ActiveX controls ?

--Richard.

 

Re:ActiveX-Ctrl termination during "Loaded" processing


Peter,

Quote
>Add a property to the form or the control that signals whether the load was
>successful or not. Then edit the projects DPR file like this

>Begin
>  Application.Initialize;
>  Application.CreateForm( Tmainformclass, mainform );
>  If not mainform.LoadSucceeded Then Exit;

>  ...other CreateForms....
>  Application.Run;
>End.

>Of course it would be even better to recode the thing in a way that makes
>the critical tests *before* the main form is created, if this is at all
>feasable.

 Your method is efficient to stop the app. from running but does not solve
my problem.

For one thing : I need to build a component which will work despite how bad
the "client" for this component has written its application. Therefore,
ideally, I have to do the trick in my component. That's why I was using the
deadly "halt" instruction.

If you do what you told me and if you have an ActiveX component on your main
form, you will be very likely to get runtime error 216 (tried with chartfx
or acrobat reader ocx).

  I suspect this is because OLE component are a little slow to stop.
But this is not a problem I guess as I am able to free the TOleControl
descendant during the 'loaded' process of my component.
 That way, I supress the Ax component because they get the chance to really
run. At least that is the way I understand it, but I need confirmation.
I still wonder if it will not cause any trouble for some application.

Thanks,

--Richard.

Re:ActiveX-Ctrl termination during "Loaded" processing


Quote
In article <7qdc6b$5...@forums.borland.com>, Richard Manson wrote:
> I suspect this is because OLE component are a little slow to stop.
> But this is not a problem I guess as I am able to free the TOleControl
> descendant during the 'loaded' process of my component.
>  That way, I supress the Ax component because they get the chance to really
> run. At least that is the way I understand it, but I need confirmation.

Well, i have no experience whatever with ActiveX controls so you will not get
a statement from me on that matter <g>.

Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitly requested!

Other Threads