Closing Event 
Author Message
 Closing Event

The problem is the closing event gets fired when a form is hidden, unloaded
and also when the user hits 'X'.
It wouldn't be a problem but the sender object is always the form (or at
least has the forms name).

How can I tell if the user hit X or the form is just bring unloded/hidden?

--
Matthew Hazlett
hazlema (at) fragnet (dot) net
"Waiting for the day C++ and VB are one big happy inherited function"

Notice:
if you email a reply to this post use the email address at the bottom of the
post and not the reply to address.



Sat, 29 Jan 2005 03:25:22 GMT  
 Closing Event
I use the following code.

Private m_sysmenuClose As Boolean = false
Public Const SC_CLOSE As Integer = 61536
Public Const WM_SYSCOMMAND As Integer = 274

Protected Overloads Overrides Sub WndProc(ByRef m As Message)
    If m.Msg = WM_SYSCOMMAND AndAlso m.WParam.ToInt32 = SC_CLOSE Then
        m_sysmenuClose = True
    End If
    MyBase.WndProc(m)
End Sub


Quote:
> The problem is the closing event gets fired when a form is hidden,
unloaded
> and also when the user hits 'X'.
> It wouldn't be a problem but the sender object is always the form (or at
> least has the forms name).

> How can I tell if the user hit X or the form is just bring unloded/hidden?

> --
> Matthew Hazlett
> hazlema (at) fragnet (dot) net
> "Waiting for the day C++ and VB are one big happy inherited function"

> Notice:
> if you email a reply to this post use the email address at the bottom of
the
> post and not the reply to address.



Sat, 29 Jan 2005 04:12:44 GMT  
 Closing Event

Thanks for the tip...

--
Matthew Hazlett
hazlema (at) fragnet (dot) net
"Waiting for the day C++ and VB are one big happy inherited function"

Notice:
if you email a reply to this post use the email address at the bottom of the
post and not the reply to address.


Quote:
> I use the following code.

> Private m_sysmenuClose As Boolean = false
> Public Const SC_CLOSE As Integer = 61536
> Public Const WM_SYSCOMMAND As Integer = 274

> Protected Overloads Overrides Sub WndProc(ByRef m As Message)
>     If m.Msg = WM_SYSCOMMAND AndAlso m.WParam.ToInt32 = SC_CLOSE Then
>         m_sysmenuClose = True
>     End If
>     MyBase.WndProc(m)
> End Sub



> > The problem is the closing event gets fired when a form is hidden,
> unloaded
> > and also when the user hits 'X'.
> > It wouldn't be a problem but the sender object is always the form (or at
> > least has the forms name).

> > How can I tell if the user hit X or the form is just bring
unloded/hidden?

> > --
> > Matthew Hazlett
> > hazlema (at) fragnet (dot) net
> > "Waiting for the day C++ and VB are one big happy inherited function"

> > Notice:
> > if you email a reply to this post use the email address at the bottom of
> the
> > post and not the reply to address.



Sat, 29 Jan 2005 05:35:43 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Form close event occurs before lost focus event

2. Help! BeforeUpdate and Close Events

3. Open / Close events with FilterOn

4. Sending data from the current record of a form on Close event

5. How trapping CommandBar Close Event

6. Canceling close events

7. Close Event for Databases in Access

8. Trapping mail read, open and close events in VBA - help please

9. Excel close event

10. Close event

11. How do I trap the close event for a standard email messages

12. how to get always the active inspector for close event

 

 
Powered by phpBB® Forum Software