Determining cursor position?

D

Dennis

Is there a way to determine the location of a "mouse down"
event on the active page?
 
M

Matt

Hi Dennis
maybe this exerpt from the MSDN Site might help?
==========
Mouse Events for Shapes
Visio mouse events are exposed on Page and Window objects. To locate a
particular shape in a page or window on which a user clicks, developers must
use the Visio SpatialSearch method. The following C# code passes in the x-
and y- coordinates for the click event on the window, sets Visio constants
that dictate how to set up the selection object, and defines a small
tolerance in which to search around the x- and y- coordinates.

MySelection = Window.SpatialSearch(x, y, visSpatialContainedIn,
0.001, visSpatialFrontToBack)
If the tolerance is set to a very small unit relative to the size of the
shape, the selection object returned by the SpatialSearch method will only
contain one shape, the one that the end user clicked on in the window.

=================

from:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odc_vis2003
_ta/html/odc_VSProgrammingwithVisioActiveXControl.asp

Regards

Matt
 
M

Matt

Ok Dennis your intention wasn't so clear.

Maybe you could use this code here
http://www.developersdex.com/gurus/articles/386.asp?Page=1

it's basically meant to create a context menu for an MS-Access treeview
control (which has no contextmenu property by default).
Kirby uses the mouse coordinates to position the menu-form near the mouse
pointer. I think you will be able to adapt the code and pass the mouse
coordinates to the dropping coordinates of your shape.

btw. I had to change "Winrect" to "rect" to get it to work.

Good luck

Matt
 
T

tlewis

I am also seeking how to capture mouse events on the page,
not on shapes; from there I can use GetCursorPos() and
other APIs, but am looking for a way to determine mouse
movement, etc., via events on the active page.
 
A

Al Edlund

I don't believe that visio supports that type of mouse events, at least it
has been reported as such.
Al
 
A

Alex [MS]

Visio 2003 supports mouse and key events. Here's some VBA to print out the
coordinates of mouse-down on the page:

Dim WithEvents visApp As Visio.Application

Sub Setup()
Set visApp = Application
End Sub

Private Sub visApp_MouseDown(ByVal Button As Long, ByVal KeyButtonState As
Long, ByVal x As Double, ByVal y As Double, CancelDefault As Boolean)
Debug.Print x & ", " & y
End Sub
 

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