Closing the form

  • Thread starter Thread starter Nenad Dobrilovic
  • Start date Start date
N

Nenad Dobrilovic

Hi,
is there any way to find out how form was closed (by calling it's method
Close() or by clicking on the 'close' button in control box)?
Also, can I close the form in that way that Cloing/Closed events are not
triggered?
 
Hi
i am not sure if this can be done , the closing event will be fired any
way ( by calling the close method or by a user click ). You can workaround
that however by catching the mouseClick event . and get its coordination .
if it falls with in the area of the close X sign on your form ( you can
easy know that knowing the size of your form) then set some Boolean
variable that indicate that form was closed by the user . then inside the
closing event handler check for that Boolean and do your logic accordingly
.. hope that helps

Mohamed Mahfouz
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC
 
Mohamoss said:
Hi
i am not sure if this can be done , the closing event will be fired any
way ( by calling the close method or by a user click ). You can workaround
that however by catching the mouseClick event . and get its coordination .
if it falls with in the area of the close X sign on your form ( you can
easy know that knowing the size of your form) then set some Boolean
variable that indicate that form was closed by the user . then inside the
closing event handler check for that Boolean and do your logic accordingly
hope that helps

Mohamed Mahfouz
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC

Thank you, it could help.
I think that is a way to find out a cause of closing the window (by
peeking in Windows messages), but it seems that it is not implemented in
..NET.
Also, closing event on child form is not firing when parent form is
closed, so I was hoping that is a way to close any form without firing
that event.
 
Back
Top