How to find the reasons for Form's unloading/closing

This is a discussion on How to find the reasons for Form's unloading/closing within the Delphi forums in Programming Languages category; I have not been able to find any way for detecting the reasons for Form's unloading/closing. How can we find out the reason for which form is being unloaded/closed...? OnClose event is not helpful here. I have managed to list the following reasons: - User clicks on the close button - Form is told to close from code - User is logging off Windows - Windows is shutting down - User closes End Task's the program from Task Manager TIA Yogi Yang...

Go Back   Application Development Forum > Programming Languages > Delphi

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 08-07-2008, 09:35 AM
Yogi Yang 007
Guest
 
Default How to find the reasons for Form's unloading/closing

I have not been able to find any way for detecting the reasons for
Form's unloading/closing.

How can we find out the reason for which form is being
unloaded/closed...? OnClose event is not helpful here.

I have managed to list the following reasons:
- User clicks on the close button
- Form is told to close from code
- User is logging off Windows
- Windows is shutting down
- User closes End Task's the program from Task Manager

TIA

Yogi Yang
Reply With Quote
  #2  
Old 08-07-2008, 01:00 PM
Remy Lebeau \(TeamB\)
Guest
 
Default Re: How to find the reasons for Form's unloading/closing


"Yogi Yang 007" <yogiyang007@gmail.com> wrote in message
news:489afa38@newsgroups.borland.com...

> I have not been able to find any way for detecting the reasons
> for Form's unloading/closing.


Because there is no such information provided anywhere for that, neither by
the VCL or the OS.

> How can we find out the reason for which form is being unloaded/closed...?


You don't. Not programmably, anyway.

> - User clicks on the close button


A WM_SYSCOMMAND message with the SC_CLOSE flag specified is issued to the
form. If the message reaches the default handler, a WM_CLOSE message is
then issued to the form. If the form is shown modally, it closes itself and
hides. Otherwise, depending on the result of the OnClose event, the form
either frees itself, hides itself, or does nothing.

> - Form is told to close from code


That hides the window immediately, and optionally frees the form depending
on result of the OnClose event.

> - User is logging off Windows
> - Windows is shutting down


A WM_QUERYENDSESSION message is issued to the form. The OnCloseQuery event
is fired. If CanClose is True, a WM_ENDSESSION message is then issued to
the TApplication window, terminating the app.

> - User closes End Task's the program from Task Manager


The TM issues WM_CLOSE and/or WM_QUIT messages to the message queues of the
process's threads. If the process does not end in a timely fashion, a brute
force termination is then performed, which the application has no chance of
responding that.


Gambit


Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 09:28 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.