Application won't close 
Author Message
 Application won't close

Hello all,

I have a tool window (border style=4). On this value I need to
reference variable, so when the user tries to close it with the
little x on the top corner I cancel the unload event and just
hide the form;

The form will be shown with
frmXXX.show ,me
from a menu command;

The problem is that when I try to close the main form, by pressing
the x in the top corner, the app won't close, I think it's due to the
cancel event in the tool window, which probably stops the main
form from reaching Unload.

Am I doing anything wrong, or is that a nown catch 22 type
of problem?



Sun, 01 Jan 2012 08:10:39 GMT  
 Application won't close


Quote:
> Hello all,

> I have a tool window (border style=4). On this value I need to
> reference variable, so when the user tries to close it with the
> little x on the top corner I cancel the unload event and just
> hide the form;

> The form will be shown with
> frmXXX.show ,me
> from a menu command;

> The problem is that when I try to close the main form, by pressing
> the x in the top corner, the app won't close, I think it's due to the
> cancel event in the tool window, which probably stops the main
> form from reaching Unload.

> Am I doing anything wrong, or is that a nown catch 22 type
> of problem?

In the tool window form:

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If UnloadMode = vbFormControlMenu Then
  Me.Hide
  Cancel = True
End If
End Sub

and remove anything in the Form_Unload event that would cancel the unload
(don't ever cancel the unload event as that is not reliable).  That will let
the tool window close on the parent unloading, an explicit Unload statement,
or anything except the user clicking the close button.



Sun, 01 Jan 2012 08:19:08 GMT  
 Application won't close


Quote:
> I have a tool window (border style=4). On this value I need to
> reference variable, so when the user tries to close it with the
> little x on the top corner I cancel the unload event and just
> hide the form;

If you never let the form unload, how is the app supposed to close?

Use the QueryUnload event instead, where you can use UnloadMode
to determine if the user hit the X or your own code is trying to close
the form, and can then act accordingly...

LFS



Sun, 01 Jan 2012 08:26:41 GMT  
 Application won't close

Quote:
> Hello all,

> I have a tool window (border style=4). On this value I need to
> reference variable, so when the user tries to close it with the
> little x on the top corner I cancel the unload event and just
> hide the form;

> The form will be shown with
> frmXXX.show ,me
> from a menu command;

> The problem is that when I try to close the main form, by pressing
> the x in the top corner, the app won't close, I think it's due to the
> cancel event in the tool window, which probably stops the main
> form from reaching Unload.

> Am I doing anything wrong, or is that a nown catch 22 type
> of problem?



Sun, 01 Jan 2012 20:16:59 GMT  
 Application won't close
Thank you, this is working now as it should.


Sun, 01 Jan 2012 22:55:26 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Quitting Application won't close Access 7.0

2. Tip : VB.NET Form Won't Close on Me.Close + User Controls

3. Access won't close after 'application.close'

4. Close from Control Box Doesn't Close Application

5. Access '97 won't close

6. Two Q's [Closing a file][why won't work]

7. Exiting applications with 'Close' button

8. Detecting when a 'shell'ed application has closed

9. Closing an 'unknown' application with VB5

10. closing win applications

11. Access won't close

12. Access won't close

 

 
Powered by phpBB® Forum Software