Getting event in .Net of Custom button from Custom menu

S

Shahzad Godil

I have added one Custom menu in shape context menuset using this code. Menu
is appearing but I want to get click event of this button in my vb.net
application using Visio ActivexControl.

Thanks
Shahzad Godil

Public Sub MenuItem_Add()

Dim uiObj As UIObject
Dim visMenuSets As MenuSets
Dim visMenuSet As MenuSet
Dim visMenus As Menus
Dim visMenu As Menu
Dim visMenuItems As MenuItems
Dim visMenuItem As MenuItem

uiObj = objApp.BuiltInMenus
visMenuSets = uiObj.MenuSets
' Get the Visio object context menu set.
visMenuSet =
visMenuSets.ItemAtID(VisUIObjSets.visUIObjSetCntx_DrawObjSel)
visMenus = visMenuSet.Menus
' Get the file menu from the menus collection.
visMenu = visMenus.Item(0)
' Get the items collection from the file menu
visMenuItems = visMenu.MenuItems

' Add Example Menu Item to the File menu in the 4th position
visMenuItem = visMenuItems.AddAt(3)
visMenuItem.Caption = "Example"
visMenuItem.State = VisUIButtonState.visButtonUp

' Have Example run the HelloWorld Sub procedure
visMenuItem.AddOnName = "ThisDocument.HelloWorld"

' Set the new menus.

objApp.SetCustomMenus(uiObj)
' Tell Visio to use the new UI when the document is active.
objDocument.SetCustomMenus(uiObj)



End Sub


End Sub
 
C

Chris [Visio MVP]

I think you have to go about it another way, using QueueMarkerEvent.

You set:

theMenu.AddOnName = QueueMarkerEvent
theMenu.AddOnArgs = "MyAddon.Event.TheMenuClicked"

Then you listen for marker events at the Visio application level. You can
quickly screen for your events by looking for "MyAddon" at the beginning of
the event string. "MyAddon.Event.TheMenuClicked" is not an offical syntax,
it's just something that I use. You can use any string.

Check out the developer help on "Marker Events" and "QueueMarkerEvent"
 
S

Shahzad Godil

Thanks. My problem solved by implememnting EventSink example in SDK Code
Viewer.

Shahzad Godil
 

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