Hi John, Here's an explanation on why it did not work, and a possible workaround: http://www.delphigroups.info/2/56/79952.html
Cheers. On Apr 9, 2012, at 10:11 PM, John Barrat wrote: > I have made a try at that but wasn't successful but I think I did it on the > main form rather than the application level. Thanks, I will try your > approach. > > JohnB > > -----Original Message----- > From: [email protected] [mailto:[email protected]] On Behalf > Of Betta International > Sent: 08 April 2012 19:59 > To: Moderated List for the Discussion of Delphi Programming excluding > Database-related topics > Subject: RE: How to close modal form when focus moved to another application > > Hi John, > > I believe windows does not notify the active window when its application > lost focus. So OnDeactivate event of your modal form won't be fired. > > I think the work around is handling OnDeactivate on application level (i.e. > through TApplicationEvents). Then find topmost form of your application and > trigger its OnDeactivate event. > > Note that while I believe this will work, but not tested. > > > Regards, > Luthfi > > --- On Fri, 4/6/12, John Barrat <[email protected]> wrote: > >> From: John Barrat <[email protected]> >> Subject: RE: How to close modal form when focus moved to another > application >> To: "'Moderated List for the Discussion of Delphi Programming excluding > Database-related topics'" <[email protected]> >> Date: Friday, April 6, 2012, 9:34 PM >> On the OnDeactivate event of the >> modal form, do a ModalResult := mrCancel; >> >> I had already tried the obvious - it doesn't work >> >> JohnB > > _______________________________________________ > Delphi mailing list > [email protected] > http://lists.elists.org/cgi-bin/mailman/listinfo/delphi > > _______________________________________________ > Delphi mailing list > [email protected] > http://lists.elists.org/cgi-bin/mailman/listinfo/delphi > _______________________________________________ Delphi mailing list [email protected] http://lists.elists.org/cgi-bin/mailman/listinfo/delphi

