QueryCancelQuit being fired more than once

M

Michael Hlavinka

Why is the QueryCancelQuit event being fired more than
once in Visio 2002/SR-1. (It does not appear to be fired
more than once in Visio 2003.) Consider the following
code:

Dim WithEvents A As Application
Dim Count As Long
Sub setit()
Set A = New Visio.Application
A.Visible = True
Count = 0
End Sub
Private Function A_QueryCancelQuit(ByVal app As
IVApplication) As Boolean
Count = Count + 1
A_QueryCancelQuit = False
End Function
Sub reset()
MsgBox Count
Set A = Nothing
End Sub

If you run the setit macro to create a new instance of
Visio, then immediately close the new instance using the
File->Exit menu item, you receive two calls to the
QueryCancelQuit event. You can run the reset macro after
the application shuts down to get the count value.

If you cancel on the second call, the application
continues to shutdown.

I believe this is some sort of bug. Is this a known
problem that was fixed in Visio 2003?

Thanks,

Michael
 
M

Mark Nelson [MS]

I seem to recall that this was a problem fixed in 2003. It may have been
related to specific drawing types for 2002.
 
M

Michael Hlavinka

It's happened on every drawing I've tried it in in Visio 2002/SR-1.

----- Mark Nelson [MS] wrote: -----

I seem to recall that this was a problem fixed in 2003. It may have been
related to specific drawing types for 2002.
 
M

Mark Nelson [MS]

I looked up the bug. The problem was with documents closed via File > Exit
where an automation listener uses WithEvents to handle Visio events. This
problem occurred in Visio 2002 SR-1 and was fixed in Visio 2003. A
workaround for Visio 2002 is to handle events using AddAdvise rather than
WithEvents.

--
Mark Nelson
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.


Michael Hlavinka said:
It's happened on every drawing I've tried it in in Visio 2002/SR-1.

----- Mark Nelson [MS] wrote: -----

I seem to recall that this was a problem fixed in 2003. It may have been
related to specific drawing types for 2002.

--
Mark Nelson
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.


Michael Hlavinka said:
Why is the QueryCancelQuit event being fired more than
once in Visio 2002/SR-1. (It does not appear to be fired
more than once in Visio 2003.) Consider the following
code:
Dim Count As Long
Sub setit()
Set A = New Visio.Application
A.Visible = True
Count = 0
End Sub
Private Function A_QueryCancelQuit(ByVal app As
IVApplication) As Boolean
Count = Count + 1
A_QueryCancelQuit = False
End Function
Sub reset()
MsgBox Count
Set A = Nothing
End Sub
Visio, then immediately close the new instance using the
File->Exit menu item, you receive two calls to the
QueryCancelQuit event. You can run the reset macro after
the application shuts down to get the count value.
problem that was fixed in Visio 2003?
 
M

Michael Hlavinka

We're using AddAdvise in a C++ application and the problem occurs there as well (that's how we initially encountered the problem). We're not using the IDL dispinterfaces that are used with the VBA WithEvents keyword in C++

Michael
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top