WUGNET, the Windows User Group Network
Your Complete Resource Center for "The Best" in Shareware, Computing Tips and Support, Windows Industry News... and much more!
Home Forums Shareware Windows Tips Hot Offers FREE Newsletters Arcade Contact Us About Partners
Search WUGNET: RSS Feeds RSS Feeds Advertise with WUGNET    |    Shareware eBooks
HomeHome FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Windows collection events unreliable

 
   Home -> Office other -> TroubleShooting RSS
Next:  Printing on large format printer  
Author Message
J Kallay

External


Since: Mar 22, 2007
Posts: 54



(Msg. 1) Posted: Mon Apr 21, 2008 12:54 pm
Post subject: Windows collection events unreliable
Archived from groups: microsoft>public>visio>troubleshoot (more info?)

I posted this on microsoft.public.visio.developer but haven't seen any
follow-ups, so I'll try again here.

I am seeing some very serious and strange problems with the raising of
events from a Windows collection. Specifically, I'm looking at
BeforeWindowClosed and QueryCancelWindowClose events (with the intent of
detecting when an add-on anchor window is being closed). In VBA, the "Got
here" line is printed reliably whenever windows such as the Pan and Zoom or
Shape Data window are closed.

Dim WithEvents vsoWindows As Windows
Public Sub Test()
Set vsoWindows = ActiveWindow.Windows

End Sub

Private Sub vsoWindows_BeforeWindowClosed(ByVal Window As IVWindow)
Debug.Print "Got here"
End Sub

However, in a C# add-in:

Using C# delegates, i.e.
m_activewin.BeforeWindowClosed+=new
Microsoft.Office.Interop.Visio.EWindow_BeforeWindowClosedEventHandler(Window_BeforeWindowClosed);

the delegate method will not get called on the first document I open and set
up with events. When I close that document and open a second one, the
method will get called once when I close one of the windows, but will never
get called again.

Using the AddAdvise method, i.e.
object eventHandler = new EventSink();
Visio.EventList eventsWindow =m_activewin.Windows.EventList;
eventsWindow.AddAdvise((short)Visio.VisEventCodes.visEvtDel+(short)Visio.VisEventCodes.visEvtWindow,
eventHandler, "", "");

eventHandler.VisEventProc will not get called at all.

Using the delegate method AND VisEventProc together is where it gets
interesting:
1) The delegate method will not get called.
2) eventHandler.VisEventProc will get called once every time a window is
closed on the first, third, etc. document that I open and close.
3) eventHandler.VisEventProc will get called twice every time a window is
closed on the second, fourth, etc. document. Note that I do not ever remove
the delegate event handler when a document is closed.

--
Jonathan Kallay
Visimation Inc.
www.visimation.com
www.shapesource.com
Back to top
Login to vote
Paul Herber

External


Since: Oct 03, 2006
Posts: 1466



(Msg. 2) Posted: Tue Apr 29, 2008 2:41 pm
Post subject: Re: Windows collection events unreliable [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Mon, 21 Apr 2008 12:54:37 -0700, "J Kallay"
<jonathank-nospam RemoveThis @visimation.com> wrote:

>I posted this on microsoft.public.visio.developer but haven't seen any
>follow-ups, so I'll try again here.
>
> I am seeing some very serious and strange problems with the raising of
>events from a Windows collection. Specifically, I'm looking at
>BeforeWindowClosed and QueryCancelWindowClose events (with the intent of
>detecting when an add-on anchor window is being closed).

Are you taking into account the change in Windows collection index
number when any window gets closed and others are opened?





--
Regards, Paul Herber, Sandrila Ltd.
Visio Utilities http://www.visio-utilities.sandrila.co.uk/
Back to top
Login to vote
J Kallay

External


Since: Mar 22, 2007
Posts: 54



(Msg. 3) Posted: Tue May 06, 2008 2:12 pm
Post subject: Re: Windows collection events unreliable [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

I don't see how that applies in this situation. The code that I included in
my post did not use any indexes, it added event handlers to a document's
windows collection's closing events. If a window is closed in that
document, the handler should be called.


--
Jonathan Kallay
Visimation Inc.
www.visimation.com
www.shapesource.com
"Paul Herber" <SubstituteMyFirstNameHere DeleteThis @pherber.com> wrote in message
news:u99e14d19no0gbtqaj9jtii9i4bl1okkpu@news.gradwell.net...
> On Mon, 21 Apr 2008 12:54:37 -0700, "J Kallay"
> <jonathank-nospam DeleteThis @visimation.com> wrote:
>
>>I posted this on microsoft.public.visio.developer but haven't seen any
>>follow-ups, so I'll try again here.
>>
>> I am seeing some very serious and strange problems with the raising of
>>events from a Windows collection. Specifically, I'm looking at
>>BeforeWindowClosed and QueryCancelWindowClose events (with the intent of
>>detecting when an add-on anchor window is being closed).
>
> Are you taking into account the change in Windows collection index
> number when any window gets closed and others are opened?
>
>
>
>
>
> --
> Regards, Paul Herber, Sandrila Ltd.
> Visio Utilities http://www.visio-utilities.sandrila.co.uk/
Back to top
Login to vote
Mark Nelson [MS]

External


Since: Nov 11, 2003
Posts: 1863



(Msg. 4) Posted: Tue May 06, 2008 7:14 pm
Post subject: Re: Windows collection events unreliable [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Is m_ActiveWin a global variable that stays in scope for the entire Visio
application session?

--
Mark Nelson
Office Graphics - Visio
Microsoft Corporation

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

"J Kallay" <jonathank-nospam.TakeThisOut@visimation.com> wrote in message
news:aLSdnd9aIaNeVL3VnZ2dnUVZ_hynnZ2d@speakeasy.net...
>I don't see how that applies in this situation. The code that I included
>in my post did not use any indexes, it added event handlers to a document's
>windows collection's closing events. If a window is closed in that
>document, the handler should be called.
>
>
> --
> Jonathan Kallay
> Visimation Inc.
> www.visimation.com
> www.shapesource.com
> "Paul Herber" <SubstituteMyFirstNameHere.TakeThisOut@pherber.com> wrote in message
> news:u99e14d19no0gbtqaj9jtii9i4bl1okkpu@news.gradwell.net...
>> On Mon, 21 Apr 2008 12:54:37 -0700, "J Kallay"
>> <jonathank-nospam.TakeThisOut@visimation.com> wrote:
>>
>>>I posted this on microsoft.public.visio.developer but haven't seen any
>>>follow-ups, so I'll try again here.
>>>
>>> I am seeing some very serious and strange problems with the raising of
>>>events from a Windows collection. Specifically, I'm looking at
>>>BeforeWindowClosed and QueryCancelWindowClose events (with the intent of
>>>detecting when an add-on anchor window is being closed).
>>
>> Are you taking into account the change in Windows collection index
>> number when any window gets closed and others are opened?
>>
>>
>>
>>
>>
>> --
>> Regards, Paul Herber, Sandrila Ltd.
>> Visio Utilities http://www.visio-utilities.sandrila.co.uk/
>
>
Back to top
Login to vote
J Kallay

External


Since: Mar 22, 2007
Posts: 54



(Msg. 5) Posted: Wed May 07, 2008 12:59 pm
Post subject: Re: Windows collection events unreliable [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

m_activewin is a field of an object encapsulating a document and its
associated window (which are passed to the object's constructor). To make a
long story short, yes, the variable stays in scope until the document is
closed.

--
Jonathan Kallay
Visimation Inc.
www.visimation.com
www.shapesource.com
"Mark Nelson [MS]" <marknel.TakeThisOut@online.microsoft.com> wrote in message
news:%23PT7dg%23rIHA.3632@TK2MSFTNGP04.phx.gbl...
> Is m_ActiveWin a global variable that stays in scope for the entire Visio
> application session?
>
> --
> Mark Nelson
> Office Graphics - Visio
> Microsoft Corporation
>
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
> "J Kallay" <jonathank-nospam.TakeThisOut@visimation.com> wrote in message
> news:aLSdnd9aIaNeVL3VnZ2dnUVZ_hynnZ2d@speakeasy.net...
>>I don't see how that applies in this situation. The code that I included
>>in my post did not use any indexes, it added event handlers to a
>>document's windows collection's closing events. If a window is closed in
>>that document, the handler should be called.
>>
>>
>> --
>> Jonathan Kallay
>> Visimation Inc.
>> www.visimation.com
>> www.shapesource.com
>> "Paul Herber" <SubstituteMyFirstNameHere.TakeThisOut@pherber.com> wrote in message
>> news:u99e14d19no0gbtqaj9jtii9i4bl1okkpu@news.gradwell.net...
>>> On Mon, 21 Apr 2008 12:54:37 -0700, "J Kallay"
>>> <jonathank-nospam.TakeThisOut@visimation.com> wrote:
>>>
>>>>I posted this on microsoft.public.visio.developer but haven't seen any
>>>>follow-ups, so I'll try again here.
>>>>
>>>> I am seeing some very serious and strange problems with the raising of
>>>>events from a Windows collection. Specifically, I'm looking at
>>>>BeforeWindowClosed and QueryCancelWindowClose events (with the intent of
>>>>detecting when an add-on anchor window is being closed).
>>>
>>> Are you taking into account the change in Windows collection index
>>> number when any window gets closed and others are opened?
>>>
>>>
>>>
>>>
>>>
>>> --
>>> Regards, Paul Herber, Sandrila Ltd.
>>> Visio Utilities http://www.visio-utilities.sandrila.co.uk/
>>
>>
>
>
Back to top
Login to vote
J Kallay

External


Since: Mar 22, 2007
Posts: 54



(Msg. 6) Posted: Thu May 08, 2008 5:16 pm
Post subject: Re: Windows collection events unreliable [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

OK, I understand part of the problem now, and there's a mistake in my
original post which obscured it.
The line m_activewin.WindowClosing, etc. was actually supposed to be
m_activewin.Windows.WindowsClosing. And while m_activewin is kept in scope
so long as the document is open, I guess m_activewin.Windows is a temporary
object that is not.

--
Jonathan Kallay
Visimation Inc.
www.visimation.com
www.shapesource.com
"J Kallay" <jonathank-nospam RemoveThis @visimation.com> wrote in message
news:q42dnRvCreZjbZHVnZ2dnUVZ_g6dnZ2d@speakeasy.net...
>I posted this on microsoft.public.visio.developer but haven't seen any
>follow-ups, so I'll try again here.
>
> I am seeing some very serious and strange problems with the raising of
> events from a Windows collection. Specifically, I'm looking at
> BeforeWindowClosed and QueryCancelWindowClose events (with the intent of
> detecting when an add-on anchor window is being closed). In VBA, the "Got
> here" line is printed reliably whenever windows such as the Pan and Zoom
> or Shape Data window are closed.
>
> Dim WithEvents vsoWindows As Windows
> Public Sub Test()
> Set vsoWindows = ActiveWindow.Windows
>
> End Sub
>
> Private Sub vsoWindows_BeforeWindowClosed(ByVal Window As IVWindow)
> Debug.Print "Got here"
> End Sub
>
> However, in a C# add-in:
>
> Using C# delegates, i.e.
> m_activewin.BeforeWindowClosed+=new
> Microsoft.Office.Interop.Visio.EWindow_BeforeWindowClosedEventHandler(Window_BeforeWindowClosed);
>
> the delegate method will not get called on the first document I open and
> set up with events. When I close that document and open a second one, the
> method will get called once when I close one of the windows, but will
> never get called again.
>
> Using the AddAdvise method, i.e.
> object eventHandler = new EventSink();
> Visio.EventList eventsWindow =m_activewin.Windows.EventList;
> eventsWindow.AddAdvise((short)Visio.VisEventCodes.visEvtDel+(short)Visio.VisEventCodes.visEvtWindow,
> eventHandler, "", "");
>
> eventHandler.VisEventProc will not get called at all.
>
> Using the delegate method AND VisEventProc together is where it gets
> interesting:
> 1) The delegate method will not get called.
> 2) eventHandler.VisEventProc will get called once every time a window is
> closed on the first, third, etc. document that I open and close.
> 3) eventHandler.VisEventProc will get called twice every time a window is
> closed on the second, fourth, etc. document. Note that I do not ever
> remove the delegate event handler when a document is closed.
>
> --
> Jonathan Kallay
> Visimation Inc.
> www.visimation.com
> www.shapesource.com
>
Back to top
Login to vote
Display posts from previous:   
       Home -> Office other -> TroubleShooting All times are: Eastern Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Categories:
 Windows XP
 Windows Vista
 Windows Other
 Office
  Office Other
 Security
 WinRAR
  • Home |
  • Shareware |
  • Windows Tips |
  • Hot Offers |
  • FREE Newsletters |
  • Arcade |
  • Forums |
  • eBooks |
  • About WUGNET |
  • Partners |
  • Contact

  • WUGNET Privacy Policy |
  • Link to WUGNET