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: delphi-boun...@elists.org [mailto:delphi-boun...@elists.org] 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 <j.bar...@netcom.co.uk> wrote:
> 
>> From: John Barrat <j.bar...@netcom.co.uk>
>> 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'" <delphi@elists.org>
>> 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
> Delphi@elists.org
> http://lists.elists.org/cgi-bin/mailman/listinfo/delphi
> 
> _______________________________________________
> Delphi mailing list
> Delphi@elists.org
> http://lists.elists.org/cgi-bin/mailman/listinfo/delphi
> 

_______________________________________________
Delphi mailing list
Delphi@elists.org
http://lists.elists.org/cgi-bin/mailman/listinfo/delphi

Reply via email to