PC Review


Reply
Thread Tools Rate Thread

Close Event ?

 
 
Stan Sainte-Rose
Guest
Posts: n/a
 
      16th Dec 2003
Hi,
Which event is called when the user click on the close window icon (X) ?
I want, when he clicks on this icon, to display a message before closing the
form.
If he replys by No, I don't want to close the form.

Thks for your help

Stan


 
Reply With Quote
 
 
 
 
Blumidoo
Guest
Posts: n/a
 
      16th Dec 2003
> Hi,
> Which event is called when the user click on the close window icon (X) ?
> I want, when he clicks on this icon, to display a message before closing

the
> form.
> If he replys by No, I don't want to close the form.


From the doc:

Form.Closing Event [Visual Basic]
Occurs when the form is closing.
[Visual Basic]
Public Event Closing As CancelEventHandler

The Closing event occurs as the form is being closed. When a form is closed,
all resources created within the object are released and the form is
disposed. If you cancel this event, the form remains opened. To cancel the
closure of a form, set the Cancel property of the CancelEventArgs passed to
your event handler to true.
When a form is displayed as a modal dialog box, clicking the Close button
(the button with an X at the upper-right corner of the form) causes the form
to be hidden and the DialogResult property to be set to DialogResult.Cancel.
You can override the value assigned to the DialogResult property when the
user clicks the Close button by setting the DialogResult property in an
event handler for the Closing event of the form.
Note When the Close method is called on a Form displayed as a modeless
window, you cannot call the Show method to make the form visible, because
the form's resources have already been released. To hide a form and then
make it visible, use the Control.Hide method.
CAUTION The Form.Closed and Form.Closing events are not raised when the
Application.Exit method is called to exit your application. If you have
validation code in either of these events that must be executed, you should
call the Form.Close method for each open form individually before calling
the Exit method.
If the form is an MDI parent form, the Closing events of all MDI child forms
are raised before the MDI parent form's Closing event is raised. In
addition, the Closed events of all MDI child forms are raised before the
Closed event of the MDI parent form is raised

sincerely,
--
Sebastian Zaklada
Skilled Software
http://www.skilledsoftware.com
************************************
SQL Source Control 2003 - for
SQL Server Source Safe integration
and custom databases documentation


 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      16th Dec 2003
* "Stan Sainte-Rose" <(E-Mail Removed)> scripsit:
> Which event is called when the user click on the close window icon (X) ?
> I want, when he clicks on this icon, to display a message before closing the
> form.
> If he replys by No, I don't want to close the form.


\\\
Private Sub Form1_Closing( _
ByVal sender As Object, _
ByVal e As System.ComponentModel.CancelEventArgs _
) Handles MyBase.Closing
If ... Then
e.Cancel = True
End If
End Sub
///

I /hate/ applications which show a messagebox before exitting...

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
 
Reply With Quote
 
Blumidoo
Guest
Posts: n/a
 
      16th Dec 2003
> I /hate/ applications which show a messagebox before exitting...

And I hate applications that close without asking to save my work _first_...

sincerely,
--
Sebastian Zaklada
Skilled Software
http://www.skilledsoftware.com
************************************
SQL Source Control 2003 - for
SQL Server Source Safe integration
and custom databases documentation


 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      16th Dec 2003
* "Blumidoo" <(E-Mail Removed)> scripsit:
>> I /hate/ applications which show a messagebox before exitting...

>
> And I hate applications that close without asking to save my work _first_...


I would at least include an option which allows the user to turn the
messagebox off.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
 
Reply With Quote
 
Blumidoo
Guest
Posts: n/a
 
      17th Dec 2003
> > And I hate applications that close without asking to save my work
_first_...
>
> I would at least include an option which allows the user to turn the
> messagebox off.


Good point, good practice. :-)

sincerely,
--
Sebastian Zaklada
Skilled Software
http://www.skilledsoftware.com
************************************
SQL Source Control 2003 - for
SQL Server Source Safe integration
and custom databases documentation


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Outlook Email will not close during close event tsshaw78 General Software 0 4th Jun 2009 08:52 PM
Before Close Event Hide all Worksheets then Close Application RyanH Microsoft Excel Programming 0 24th Jan 2008 03:15 PM
Access Close Event: What Order Do Forms Close? misseill Microsoft Access 1 14th May 2007 10:03 PM
[C++] how to use Close Event with void Close( BOOL * Cancel) cyan21 Microsoft Outlook Program Addins 0 12th Jul 2005 12:39 PM
Save and Close does not fire Inspector.Close event Roderic Microsoft Outlook Program Addins 3 8th Oct 2004 04:11 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:30 PM.