C# visio drawing control Mouse click - X-axis and Y-axis

P

Pradeep

We are using Visio Drawing control in our C# application.
I need to capture the X-axis and Y-axis location of the mouse click when
mouse is clicked on a page in visio document.
After capturing the location, a new shape must be drawn at the mouse click
location.
Please help me out in finding the solution.
 
J

JuneTheSecond

Mouse events might be useful, examples might be find in Visio SDK Code
librarian.
 
T

timt

We are using Visio Drawing control in our C# application.
I need to capture the X-axis and Y-axis location of the mouse click when
mouse is clicked on a page in visio document.

You can register on the mousedown event of the visio drawing control:
this.MouseDownEvent += new
AxMicrosoft.Office.Interop.VisOcx.EVisOcx_MouseDownEventHandler(VisioControlEx_MouseDownEvent);

void VisioControlEx_MouseDownEvent(object sender,
AxMicrosoft.Office.Interop.VisOcx.EVisOcx_MouseDownEvent e)

In the AxMicrosoft.Office.Interop.VisOcx.EVisOcx_MouseDownEvent object
the position of the mouseclick and of the button. (e.button, e.x and
e.y).
The mouse position is returned in doubles and are visio page
coordinates and can be used directly in the shape drop action.
After capturing the location, a new shape must be drawn at the mouse click
location.

first you find the master of the shape you want to drop (via the
stencildocument):
public Master GetMaster(string masterNameU)
{
Masters targetMasters = m_filterStencilDocument.Masters;
foreach (Master m in targetMasters)
if (m.Name == masterNameU)
return m;

Master targetMaster = targetMasters.get_ItemU(masterNameU);

return targetMaster;
}

Then you can use the master to drop it at the desired location (in
your case the caught mouseclick position e.x, e.y)

Master masterShape = GetMaster(name);
((Page)this.Window.PageAsObj).Drop(masterShape, e.x, e.y);
 

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