Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2005 Nov : Close secondary applications if main application crashes

www.cryer.info
Managed Newsgroup Archive

Close secondary applications if main application crashes

Subject:Close secondary applications if main application crashes
Posted by:"Andrew Jameson" (softspotsoftwareno@spamgmail.com)
Date:Sun, 27 Nov 2005 19:46:52

Hi,
My main application launches a few secondary applications.  These secondary
applications are reparented and become embedded in my main application.  The
problem that I'd like to fix is that if the main application crashes then
the secondary applications no longer have a parent and become invisible.

The only solution so far is to pass the new parent handle to my secondary
applications and from within a timer I test :

  if (fParentHandle <> 0) and not IsWindow(fParentHandle) then
    Close;

What I'd like to be able to do is to actually perform a test :

  if (fParentHandle <> 0) and (fParentHandle <> GetMyParentHandle) then
    Close;

From the secondary application, how do I get the ParentHandle that was set
by the main application when I executed SetParent ?

On a related note ... how does Windows actually assign new handle values ?
My slight concern about my first test is that between my main application
crashing and my secondary application testing IsWindow, what's to prevent
Windows actually creating a new window unrelated to my program with the same
handle ?

Finally, any other solutions ?

Thanks

Andrew

Glossary

Replies:

www.cryer.info
Managed Newsgroup Archive