DoubleClick with Visio2003 ActiveX drawing control

A

Assalama

Hi,
I'm using Visio2003 ActiveX drawing control in a .NET windows
application. I want to add a double click event handler for a shape. I
guess the only way is to use the visEvtCellDblClick in the Events
shapesheet's section, but how can I notify my application of the event
fired? I read that any macro in the visio document will be disabled
when the control loads the document, so how can I notify my host
application?
Ps. I can not make Callthis in DBlClickcell in shapesheet like in
Visio.

Thanks,
Halim
 
S

Scott Metzger

Assalama said:
Hi,
I'm using Visio2003 ActiveX drawing control in a .NET windows
application. I want to add a double click event handler for a shape. I
guess the only way is to use the visEvtCellDblClick in the Events
shapesheet's section, but how can I notify my application of the event
fired? I read that any macro in the visio document will be disabled
when the control loads the document, so how can I notify my host
application?
Ps. I can not make Callthis in DBlClickcell in shapesheet like in
Visio.

This is a bit of a hack, but it works. You can make a User-Defined cell
and then in your DblClickcell put something like:
SETF(GetRef(User.EditFSP),User.EditFSP+1)
Then you can monitor the OnChange event for this USer-Defined cell.

Thats how I do it with my .exe that uses Visio 2002 Automation.

I was hoping that the Active-X control would make this sort of thing
'cleaner', but I don't have Visio 2003 yet. Does anyone else know of a
better way to do this with the Active-X control?

*:> Scott Metzger
 
M

Mai-lan [MS]

You can use ShapeSheet events but Visio has new events in Visio 2003 --
mouse and keyboard events -- that you can use to enable double-click as
well. Mouse events are only on the page or window, so you should use
SpatialSearch with a low tolerance to locate the shape on which you click.

Mai-lan
 
A

Assalama

Mai-lan said:
You can use ShapeSheet events but Visio has new events in Visio 2003 --
mouse and keyboard events -- that you can use to enable double-click as
well. Mouse events are only on the page or window, so you should use
SpatialSearch with a low tolerance to locate the shape on which you click.

Mai-lan

Thank you very much Mai-lan,
i can with SpatialSearch only catch a simple click event but not
double-click event. how can i do this?

Thanks
 
S

Scott Metzger

Mai-lan said:
You can use ShapeSheet events but Visio has new events in Visio 2003 --
mouse and keyboard events -- that you can use to enable double-click as
well. Mouse events are only on the page or window, so you should use
SpatialSearch with a low tolerance to locate the shape on which you click.

When you say "ShapeSheet events" does that include Action events? Or
are these still on the 'not doable' list?
 
M

Mai-lan [MS]

Hi, there: Here's some sample code for handling double click events:
private void axDrawingControl1_MouseDownEvent(object sender,
AxMicrosoft.Office.Interop.VisOcx.EVisOcx_MouseDownEvent e)
{

// Have a class member like this in the containing
form's class definition:

//

//private int m_previousMouseDownEvent= 0;



const int threshold= 200;



if (0!=m_previousMouseDownEvent &&
(System.Environment.TickCount-m_previousMouseDownEvent)<threshold)

{

// Two MouseDown events occurred within threshold
milliseconds

// of each other... Consider it a "double
click"...

//

System.Windows.Forms.MessageBox.Show("Double
clicked!");

}



m_previousMouseDownEvent = System.Environment.TickCount;

}



Use Win32's "GetTickCount" function from C++. VB6 has a Timer function.
Spatial proximity may matter to some folks. If so, they need to track the x
and y from the events also.

Thanks,

Mai-lan





--
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.
Assalama said:
"Mai-lan [MS]" <[email protected]> wrote in message
You can use ShapeSheet events but Visio has new events in Visio 2003 --
mouse and keyboard events -- that you can use to enable double-click as
well. Mouse events are only on the page or window, so you should use
SpatialSearch with a low tolerance to locate the shape on which you click.

Mai-lan

Thank you very much Mai-lan,
i can with SpatialSearch only catch a simple click event but not
double-click event. how can i do this?

Thanks
 
M

Mai-lan [MS]

Hi, Scott: What did you mean by the not-doable list? You can program against
anything in the ShapeSheet in the control. The thing that you can't do in
the control is execute VBA...

Mai-lan
 
S

Scott Metzger

Mai-lan said:
Hi, Scott: What did you mean by the not-doable list? You can program against
anything in the ShapeSheet in the control. The thing that you can't do in
the control is execute VBA...

If you make a .exe 'talk' to Visio 2002 via Automation, there is no
direct way to respond to an Action event. For example, if my shape has
an Actions section, there is no direct way for my .exe to hook into the
event that fires when the user initiates that action. There are two
ways I know of one could implement this in Visio 2002 Automation:
1) Write some VBA code in the shape which then calls Automation code in
the .exe. Complicated, slow, and not a clean solution.

2) In the Action Cell, do something like:
SETF(GetRef(User.EditFSP),User.EditFSP+1)
Then in the .exe map an CellChange event and filter out everything
except the User.EditFSP cell.
This is also not a clean or direct solution.

What I would like to do is actually map an event for the Action
directly. Is that possible with the Active-X control?

While we are talking about the Active-X control. When using C++ in a
..exe and mapping an event for Visio 2002, it looks like it is not
possible (or at least I don't know how) to map an event to a C++ member
function of a class. You can do it only to a C style function. For the
Active-X control is it possible to map a ShapeSheet event to a C++ class
member function?

Thank You,
Scott Metzger
 
B

Blair [MS]

Another alternative is to use the QueueMarker Events called via the
EventDblClick cell in the Events ShapeSheet section for the shape. Use the
following formula for example.

=RUNADDONWARGS("QueueMarkerEvent","/soln= Microsoft.Visio.Demo /cmd=1")

Register an eventhandler to receive and parse this event.

-Blair [MS]

Mai-lan said:
Hi, there: Here's some sample code for handling double click events:
private void axDrawingControl1_MouseDownEvent(object sender,
AxMicrosoft.Office.Interop.VisOcx.EVisOcx_MouseDownEvent e)
{

// Have a class member like this in the containing
form's class definition:

//

//private int m_previousMouseDownEvent= 0;



const int threshold= 200;



if (0!=m_previousMouseDownEvent &&
(System.Environment.TickCount-m_previousMouseDownEvent)<threshold)

{

// Two MouseDown events occurred within threshold
milliseconds

// of each other... Consider it a "double
click"...

//

System.Windows.Forms.MessageBox.Show("Double
clicked!");

}



m_previousMouseDownEvent = System.Environment.TickCount;

}



Use Win32's "GetTickCount" function from C++. VB6 has a Timer function.
Spatial proximity may matter to some folks. If so, they need to track the x
and y from the events also.

Thanks,

Mai-lan





--
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.
Assalama said:
"Mai-lan [MS]" <[email protected]> wrote in message
You can use ShapeSheet events but Visio has new events in Visio 2003 --
mouse and keyboard events -- that you can use to enable double-click as
well. Mouse events are only on the page or window, so you should use
SpatialSearch with a low tolerance to locate the shape on which you click.

Mai-lan

--
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.
Assalama wrote:
Hi,
I'm using Visio2003 ActiveX drawing control in a .NET windows
application. I want to add a double click event handler for a
shape.
of
a

Thank you very much Mai-lan,
i can with SpatialSearch only catch a simple click event but not
double-click event. how can i do this?

Thanks
 
M

Matt

Hello NG and Mai-lan

Is there a way to do this in VBA? I tried to adapt your code but it didn't
work.
Somehow I would have to start the timer with the mousedownevent and check
whether the time between the start time of the first mousedownevent and the
time of the second mousedownevent is <= the threshold time -right? But then
I would also have to reset the timer and so on...

I can't get this to work in VBA your help is highly appreciated.
BTW, how will this ongoing timing affect my performance?

Again many questions - hope there will be some answers.

Tia
Matt


Mai-lan said:
Hi, there: Here's some sample code for handling double click events:
private void axDrawingControl1_MouseDownEvent(object sender,
AxMicrosoft.Office.Interop.VisOcx.EVisOcx_MouseDownEvent e)
{

// Have a class member like this in the containing
form's class definition:

//

//private int m_previousMouseDownEvent= 0;



const int threshold= 200;



if (0!=m_previousMouseDownEvent &&
(System.Environment.TickCount-m_previousMouseDownEvent)<threshold)

{

// Two MouseDown events occurred within threshold
milliseconds

// of each other... Consider it a "double
click"...

//

System.Windows.Forms.MessageBox.Show("Double
clicked!");

}



m_previousMouseDownEvent = System.Environment.TickCount;

}



Use Win32's "GetTickCount" function from C++. VB6 has a Timer function.
Spatial proximity may matter to some folks. If so, they need to track the x
and y from the events also.

Thanks,

Mai-lan





--
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.
Assalama said:
"Mai-lan [MS]" <[email protected]> wrote in message
You can use ShapeSheet events but Visio has new events in Visio 2003 --
mouse and keyboard events -- that you can use to enable double-click as
well. Mouse events are only on the page or window, so you should use
SpatialSearch with a low tolerance to locate the shape on which you click.

Mai-lan

--
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.
Assalama wrote:
Hi,
I'm using Visio2003 ActiveX drawing control in a .NET windows
application. I want to add a double click event handler for a
shape.
of
a

Thank you very much Mai-lan,
i can with SpatialSearch only catch a simple click event but not
double-click event. how can i do this?

Thanks
 
M

Matt

OK I kept on trying and came up with the following which seems to work very
nice so far - any comments from the pros - do you see any probs with this
piece of VBA-code?

In the Form_Load Event of the Mainform (on which my drawingControl sits) I
put
Timer1 = 0
Timer2 =0

Then for the mousedown-event:

Private Sub MyDrawingControl_MouseDown(ByVal Button As Long, _
ByVal KeyButtonState As Long, ByVal x As Double, _
ByVal y As Double, CancelDefault As Boolean)
Dim Timer1 as Single
Dim Timer2 as Single
Dim mySel As Visio.Selection
Dim mySelShape As Visio.shape

Set mySel = myVisApp.ActivePage.SpatialSearch(x, y, visSpatialContainedIn, _
0.001, visSpatialFrontToBack)

If timer1 = timer2 Then
timer1 = Timer
Else
timer2 = Timer
If timer2 - timer1 < 1 Then 'if time difference in seconds is smaller then 1
Sec.

Set mySelShape = mySel.Item(1)
MsgBox (mySelShape.Text)
timer1 = timer2
Else
timer1 = timer2

End If
End If

End sub

If you think this code will create performance or other probs please give me
a hint. So far it works very nice but.

Regards
Matt



Matt said:
Hello NG and Mai-lan

Is there a way to do this in VBA? I tried to adapt your code but it didn't
work.
Somehow I would have to start the timer with the mousedownevent and check
whether the time between the start time of the first mousedownevent and the
time of the second mousedownevent is <= the threshold time -right? But then
I would also have to reset the timer and so on...

I can't get this to work in VBA your help is highly appreciated.
BTW, how will this ongoing timing affect my performance?

Again many questions - hope there will be some answers.

Tia
Matt


Mai-lan said:
Hi, there: Here's some sample code for handling double click events:
private void axDrawingControl1_MouseDownEvent(object sender,
AxMicrosoft.Office.Interop.VisOcx.EVisOcx_MouseDownEvent e)
{

// Have a class member like this in the containing
form's class definition:

//

//private int m_previousMouseDownEvent= 0;



const int threshold= 200;



if (0!=m_previousMouseDownEvent &&
(System.Environment.TickCount-m_previousMouseDownEvent)<threshold)

{

// Two MouseDown events occurred within threshold
milliseconds

// of each other... Consider it a "double
click"...

//

System.Windows.Forms.MessageBox.Show("Double
clicked!");

}



m_previousMouseDownEvent = System.Environment.TickCount;

}



Use Win32's "GetTickCount" function from C++. VB6 has a Timer function.
Spatial proximity may matter to some folks. If so, they need to track
the
x
and y from the events also.

Thanks,

Mai-lan





--
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.
Assalama said:
"Mai-lan [MS]" <[email protected]> wrote in message
You can use ShapeSheet events but Visio has new events in Visio 2003 --
mouse and keyboard events -- that you can use to enable double-click as
well. Mouse events are only on the page or window, so you should use
SpatialSearch with a low tolerance to locate the shape on which you click.

Mai-lan

--
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.
Assalama wrote:
Hi,
I'm using Visio2003 ActiveX drawing control in a .NET windows
application. I want to add a double click event handler for a
shape.
I
guess the only way is to use the visEvtCellDblClick in the Events
shapesheet's section, but how can I notify my application of the event
fired? I read that any macro in the visio document will be disabled
when the control loads the document, so how can I notify my host
application?
Ps. I can not make Callthis in DBlClickcell in shapesheet like in
Visio.

This is a bit of a hack, but it works. You can make a
User-Defined
cell
and then in your DblClickcell put something like:
SETF(GetRef(User.EditFSP),User.EditFSP+1)
Then you can monitor the OnChange event for this USer-Defined cell.

Thats how I do it with my .exe that uses Visio 2002 Automation.

I was hoping that the Active-X control would make this sort of thing
'cleaner', but I don't have Visio 2003 yet. Does anyone else know
of
a
better way to do this with the Active-X control?

*:> Scott Metzger


Thank you very much Mai-lan,
i can with SpatialSearch only catch a simple click event but not
double-click event. how can i do this?

Thanks
 

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