How to get context menu event

S

Shahzad Godil

I am using Visio Active Control in vb.net 2003.

I am adding few menu items in orignal context menus. It works ok when you
click on shape first to select. And in on select event, we are adding event
in this menu. But what about when user right click on shape and context
menu appear. I already check that no mouse-up, mouse-down, click event is
firing. Even the EnterScope even is not being calling when doing right
click on unselected shape.

Thanks
Shahzad Godil
 
J

JuneTheSecond

How would you feel to use RaiseEvent statement?
Events would be generated in the proc triggered by your menu.
 
O

Oguz Basoglu

Hi Shahzad,

I just ran into the same problem, and here is how I solved it (I have to
admit that it's not my own solution)

First make sure, that you modify the shape (or the master shape) by adding
an row to the actions-section.

After you have modified the shape, you will notice that the
right-mouse-context-menu is expended by your customization.

The next step is to modify your code. As I still use VB6, I use the
IVisEventProc interface. I created a class that implements IVisEventProc (I
call it clsEventSink):

Option Explicit
Implements Visio.IVisEventProc
Private Function IVisEventProc_VisEventProc(...
End Function

I create this class and create a custom event that uses my class:

Set vsoEventSink = New clsEventSink
Set vsoEventList = vsoApplication.EventList
Set vsoEvent = vsoEventList.AddAdvise(intMarkerEventCode, vsoEventSink, "",
"")

This makes my solution react to the right-mouse-action. Take a look at the
Visio SDK
(http://www.microsoft.com/downloads/...bd-b0bb-46e7-936a-b8539898d44d&DisplayLang=en)
 
S

Shahzad Godil

This is not actually I want. I already have EventSink class implemented for
my custom menu.

My case is that I am adding row in action section using code. That work
perfectly because I am adding row in section in SelectionChanged Event.

But without selecting a shape, when we are doing right click on shape, it is
not raising SelectionEvent and because of this, my code is also not calling.

Thanks
Shahzad Godil
 
A

Al Edlund

If you examine the sample for project flowchart in the v2003 sdk, I believe,
you might discover that those interrupts show up as Marker events in the
application event processing. At least that is how I implemented them.
al
 
J

JuneTheSecond

Thi is not a solution, but you might presume which context menu is shown by
examining the reply of MouseDown events.

Dim WithEvents myWin As Visio.Window
Private Sub myWin_MouseDown(ByVal Button As Long, ByVal KeyButtonState As
Long, ByVal x As Double, ByVal y As Double, CancelDefault As Boolean)
If Button = 2 Then
If myWin.Selection.Count = 0 Then
Debug.Print "Page was right clicked"
Else
If myWin.Selection.Count = 1 Then
Debug.Print myWin.Selection(1).Name & " was right clicked"
End If
End If
End If
End Sub
 
S

Shahzad Godil

Problem is that I already tried Marker event and MouseDown/MouseUp event.
MouseUp/MouseDown is being call perfectly when you do any click on anywhere
in drawing. But it is not working at all when you just right click to get
context menu on shape.
 
S

Shahzad Godil

Problem is that I already tried Marker event and MouseDown/MouseUp event.
MouseUp/MouseDown is being call perfectly when you do any click on anywhere
in drawing. But it is not working at all when you just right click to get
context menu on shape.
 
B

bnk

I think there is no 'completly robust' way to solve your issue.
But there are workarounds.

For instance, you can determine the shape under cursor whille handling
MouseUp event; If the shape is not selected, then it probably(!) will
be selected when context menu opens, so process this shape instead of
selected one, or both selected shape and the shape under cursor.
The problem with this approach is sub-selection. You'll need to handle
it specially. If you do care of sub-selection, of course :)

Can you see, I have asked similar question here a year ago..
If you'll find a strightforward light way in the darkness feel free to
inform me :)
 
S

Shahzad Godil

Thanks

My problem solved by getting selection on MouseDown event from one of SDK
function. Thanks again to solve my issue.

Shahzad Godil
Karachi-Pakistan

Public Function getMouseClickShapes( _

ByVal clickedPage As Microsoft.Office.Interop.Visio.Page, _

ByVal clickedLocationX As Double, _

ByVal clickedLocationY As Double, _

ByVal tolerance As Double) _

As Microsoft.Office.Interop.Visio.Selection
 
R

Ryo_Ohki2

I was about to suggest that.. Glad you found your solution. I had t
do the same thing for my stuff. That SDK sure has a few good items i
it
 

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