Problems with Event Handling

M

Martin

Hi all,

I extended the "Menu Bar" of Visio by one popup ("x") with a button
("y").
In order to have functionality I added my own event handler which does
nothing else than displaying a message box if the button y is clicked.

As I start Visio the menu bar is extended by my own entry and the event
handler is working. But when I open a document the event handler seems
to get lost :(

In my opinion the garbage collector might have removed it.
Does anyone know about this issue and might help me with a good
solution?

Thanks in advance,
Martin
 
A

Al Edlund

what are you developing in (vba, vb6, vb.net, c#)? Is it an add-in or
are you hosting a drawing control? A little more information might be
helpful...
al
ps garbage collection hints at vs but no version...
 
M

Martin

Oh sorry for information hiding :) I did not think about that before.
I thought it might be a more popular mistake made by beginners like me
:)

I am developing a com add-in written in c# (using the visio project
type provided by the visio 2003 sdk).
So it's Visio 2003 Prof. and Visual Studio.NET 2003 with FW 2.

I extended the preconfigured project by my own "application" class like
I read in a tutorial.
Within that class I made the UI changes in a separat method.

First of all I get the CommandBar "Menu Bar" out of the menu bars.
Then add a (CommandBar)Popup and after that I add a (CommandBar)Button.

With this line I add the Event Handler:

button.Click += new
_CommandBarButtonEvents_ClickEventHandler(buttonClicked);

After starting Visio the Event Handler works and a MsgBox is displayed
each time I click the menu.
But when I opened a document the Event Handler gets "lost" and does not
work.

That's the reason why I thought about Garbage Collection or stuff like
that :(

Ah... btw: My add-in isn't hosting drawing control.


Martin
 
M

Martin

Just FYI: I changed my concept and now all my events handlers are added
AFTER the documentOpened event. Thereby the event handling is working
without any problems.

Perhaps this could help anybody who runs into the same "problem" and
does not know what happens to him / her ;)
 

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