connectionsadded event doesn't fire in drawing control

M

Matt

Hello everybody

I can't get this to work. I was studying Chris Roth's wiring example, tried
the "Dim WithEvent as" for my active Visio page in the drawing control (got
it in the class and event list) but it doesn't fire :-((

I don't know what else to try - maybe the NG can help?

How to set up my drawing control code under VBA, to get the
connectionsAdded-event to fire?

Pls. give me some hint

Thank you very much

Matt
 
P

Peter Suter

Hi Matt

You have to initialize MyApp first!
Try this in Module 'ThisDocument'

'
Dim WithEvents MyApp As Visio.Application
'
Private Sub Document_RunModeEntered(ByVal doc As IVDocument)
Set MyApp = Application
End Sub
'
Private Sub MyApp_ConnectionsAdded(ByVal vConnects As IVConnects)
MsgBox "Event ConnectionsAdded fired: " & vConnects(1).FromSheet.NameID
End Sub
'

OK?

Peter
 
M

Matt

Hello Peter

Thank you very much for your ongoing assistance. I tried your code already
but it still doesn't fire. In the drawing control I don't have a
"ThisDocument"-class so I put the initialization in the Form_Activate (tried
also the Form_Load) procedure of the Access-subform where the control is
embeded in.
=================
Dim WithEvents MyApp as Visio.Application

Private Sub MyForm_Activate()

Set MyApp = Application
End Sub

Private Sub MyApp.ConnectionsAdded (Byval etc)
Msgbox "Fired!!!"
End Sub
========
This doesn't work :-(

So far when I wanted the Application for the control I got that with:

Set Myapp = MyDrawingControl.Window.Application
This worked great and I got all the documents, pages and shapes with that
but not the connectionsAdded event.
Also the Eventlist of the MyDrawingControl doesn't show this event.

Is there a way to add this event to the eventlist of the MyDrawingControl -
because the Shapesadded event or the Selectionchanged-event fire very
nicely?

Thank you very much and best regards to Bern
Matt
 
P

Peter Suter

Hi Matt
Your code seems not to be correct -
Try again in your Form:
'
Option Explicit
'
Public WithEvents vsoApplication As Visio.Application
'
'------------------------------------
Private Sub Form_Load()
'------------------------------------
Set vsoApplication = DrawingControl0.Window.Application
'
' some other Code here
'
End Sub
'
'-------------------------------------------------------------------
Private Sub vsoApplication_ConnectionsAdded(ByVal voConnects As
Visio.Connects)
'--------------------------------------------------------------------
MsgBox "Event in Form fired: Connections added ..." &
voConnects.Item(1).FromSheet.NameID
End Sub
'
'
Ok now ?

Peter
 
M

Matt

Hi Peter
First it didn't fire again but now I found the problem:
The control is embeded in a subform which itself sits in a Mainform. Because
all the standard events like "shapeAdded" etc. work in the subform, I kept
on trying to add the code to the subform - w/o success.
Finally I added your code to the Mainform - and IT FIRES - YES!!!!!

Is there some logic behind this behavior, so I can plan future event code
differently? Why some events fire from the subform and some only from the
Mainform - both with the same control?

Thank you very much for your patience and support

Greetings
Matt
 
P

Peter Suter

Matt
Congratulations!
Because I'm working in Visio 2003 and VB.NET, I dont't have great
experiences with the
DrawingControl. And I don't know your code.
As you can verify in the Editors ListView's on the top-right-side, there
are only a few Event's noted.
Don't ask me why. Ask the Guru's! We have all to learn ..
In the meantime, I'm faster with Try and Error ... ;-))

Peter
 
M

Matt

Yes - trial and error is definately eating up most of my time at the
moment...;-))))

Maybe Mai-lan or Senaj are reading this and can shed some light on the event
handling on different Access-form levels...

Anyway it keeps on firering now and I'm very happy!

Thank you one more time
regards
Matt
 
M

Mai-lan [MS]

Hi, there: Just saw this one. So, I'm a little confused on the scenario. Do
you have the control on two forms in the same app? One on a main form and
the other on a sub-form? If so, the control can be used multiple times in a
single app (like on multiple forms) but it's important to keep in mind that
it shares an underlying Application object. So for examples, this can get a
little nasty when you're referencing members of a collection like the
Windows collection. We recommend that you index directly into a collection
when working with multiple instances of the control and never do any menu
merging -- the app objects gets pretty confused.

If you are working with multiple instances of the control on different
forms, your event handling issues might be tied to some confusion in the app
object for who is firing what event. But this is just a wild guess, it's
hard to say for the code snip without full context what's going on. I'm glad
it is working, though!

Thanks,
Mai-lan
 
M

Matt

Thanks Mai-lan for your comments - but No I'm not working with different
controls/instances. The scenario in Access was(!) at that time:
One Main-form (which is maximized at load time) (myMain)
On that Main-form sat a tab-control (myTab)
On the first page of the tab-control was a sub-form (mygrphForm)
On that subform finally was the drawingControl (myControl)

What confused me was the fact that I always put the code for drawingcontrol
in the subform (mygrphForm) and it worked fine.
But when I tried to get the connectionadded-event to fire it didn't do this
in the subform - only in the Mainform (myMain).
So Peter and I just wanted to learn more about the logic behind that.

Tia
Matt

BTW: Meanwhile I eliminated the subform and placed the drawingcontrol
directly on the tab-control. All the code for it goes now in the Mainform.
 
M

Mai-lan [MS]

To be honest, I don't know. We get some weird behavior in Access sometimes
(I posted a message about some of the behaviors earlier). Access also has
some unique behaviors with ActiveX controls. For example, while the control'
s properties are available, you can't get to the control's API without
explicitly using the Object property. Access puts a non-type-specific (as
Object/IDispatch) layer around its embedded controls. So to get to the
control in Access 11, we have to do something like:
Dim visControl as VisOCX.DrawingControl

Set visControl =DrawingControl.Object

At this point, I would chalk up the strange behavior as container-specific.

Sorry not to have anything more concrete,
Mai-lan
 
M

Matt

Thanks Mai-lan
I think it's very good for our self-confidence, that also the "wise" gurus
not always have an easy answer to our questions ...;-)

Best regards
Matt
 
M

Mai-lan [MS]

We're only wise when we know when to say we don't know. ;-)

Mai-lan

--
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.
Matt said:
Thanks Mai-lan
I think it's very good for our self-confidence, that also the "wise" gurus
not always have an easy answer to our questions ...;-)

Best regards
Matt


Mai-lan said:
To be honest, I don't know. We get some weird behavior in Access sometimes
(I posted a message about some of the behaviors earlier). Access also has
some unique behaviors with ActiveX controls. For example, while the control'
s properties are available, you can't get to the control's API without
explicitly using the Object property. Access puts a non-type-specific (as
Object/IDispatch) layer around its embedded controls. So to get to the
control in Access 11, we have to do something like:
Dim visControl as VisOCX.DrawingControl

Set visControl =DrawingControl.Object

At this point, I would chalk up the strange behavior as container-specific.

Sorry not to have anything more concrete,
Mai-lan
--
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.
Matt said:
Thanks Mai-lan for your comments - but No I'm not working with different
controls/instances. The scenario in Access was(!) at that time:
One Main-form (which is maximized at load time) (myMain)
On that Main-form sat a tab-control (myTab)
On the first page of the tab-control was a sub-form (mygrphForm)
On that subform finally was the drawingControl (myControl)

What confused me was the fact that I always put the code for drawingcontrol
in the subform (mygrphForm) and it worked fine.
But when I tried to get the connectionadded-event to fire it didn't do this
in the subform - only in the Mainform (myMain).
So Peter and I just wanted to learn more about the logic behind that.

Tia
Matt

BTW: Meanwhile I eliminated the subform and placed the drawingcontrol
directly on the tab-control. All the code for it goes now in the Mainform.


Hi, there: Just saw this one. So, I'm a little confused on the scenario.
Do
you have the control on two forms in the same app? One on a main
form
and
the other on a sub-form? If so, the control can be used multiple
times
in
a
single app (like on multiple forms) but it's important to keep in mind
that
it shares an underlying Application object. So for examples, this
can
get
a
little nasty when you're referencing members of a collection like the
Windows collection. We recommend that you index directly into a collection
when working with multiple instances of the control and never do any menu
merging -- the app objects gets pretty confused.

If you are working with multiple instances of the control on different
forms, your event handling issues might be tied to some confusion in the
app
object for who is firing what event. But this is just a wild guess, it's
hard to say for the code snip without full context what's going on. I'm
glad
it is working, though!

Thanks,
Mai-lan

--
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no
rights.
Yes - trial and error is definately eating up most of my time at the
moment...;-))))

Maybe Mai-lan or Senaj are reading this and can shed some light on the
event
handling on different Access-form levels...

Anyway it keeps on firering now and I'm very happy!

Thank you one more time
regards
Matt


Newsbeitrag
Matt
Congratulations!
Because I'm working in Visio 2003 and VB.NET, I dont't have great
experiences with the
DrawingControl. And I don't know your code.
As you can verify in the Editors ListView's on the top-right-side,
there
are only a few Event's noted.
Don't ask me why. Ask the Guru's! We have all to learn ..
In the meantime, I'm faster with Try and Error ... ;-))

Peter
 
M

Matt

Very wise - indeed :D :D :D

Matt

Mai-lan said:
We're only wise when we know when to say we don't know. ;-)

Mai-lan

--
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.
Matt said:
Thanks Mai-lan
I think it's very good for our self-confidence, that also the "wise" gurus
not always have an easy answer to our questions ...;-)

Best regards
Matt


Mai-lan said:
To be honest, I don't know. We get some weird behavior in Access sometimes
(I posted a message about some of the behaviors earlier). Access also has
some unique behaviors with ActiveX controls. For example, while the control'
s properties are available, you can't get to the control's API without
explicitly using the Object property. Access puts a non-type-specific (as
Object/IDispatch) layer around its embedded controls. So to get to the
control in Access 11, we have to do something like:
Dim visControl as VisOCX.DrawingControl

Set visControl =DrawingControl.Object

At this point, I would chalk up the strange behavior as container-specific.

Sorry not to have anything more concrete,
Mai-lan
--
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.
Thanks Mai-lan for your comments - but No I'm not working with different
controls/instances. The scenario in Access was(!) at that time:
One Main-form (which is maximized at load time) (myMain)
On that Main-form sat a tab-control (myTab)
On the first page of the tab-control was a sub-form (mygrphForm)
On that subform finally was the drawingControl (myControl)

What confused me was the fact that I always put the code for
drawingcontrol
in the subform (mygrphForm) and it worked fine.
But when I tried to get the connectionadded-event to fire it didn't do
this
in the subform - only in the Mainform (myMain).
So Peter and I just wanted to learn more about the logic behind that.

Tia
Matt

BTW: Meanwhile I eliminated the subform and placed the drawingcontrol
directly on the tab-control. All the code for it goes now in the Mainform.


Hi, there: Just saw this one. So, I'm a little confused on the scenario.
Do
you have the control on two forms in the same app? One on a main form
and
the other on a sub-form? If so, the control can be used multiple times
in
a
single app (like on multiple forms) but it's important to keep in mind
that
it shares an underlying Application object. So for examples, this can
get
a
little nasty when you're referencing members of a collection like the
Windows collection. We recommend that you index directly into a
collection
when working with multiple instances of the control and never do any
menu
merging -- the app objects gets pretty confused.

If you are working with multiple instances of the control on different
forms, your event handling issues might be tied to some confusion
in
the
app
object for who is firing what event. But this is just a wild
guess,
it's
hard to say for the code snip without full context what's going
on.
I'm
glad
it is working, though!

Thanks,
Mai-lan

--
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no
rights.
Yes - trial and error is definately eating up most of my time at the
moment...;-))))

Maybe Mai-lan or Senaj are reading this and can shed some light
on
the
 

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