User defiened menus handling

  • Thread starter Yevgeny Barkovsky
  • Start date
Y

Yevgeny Barkovsky

One more newbie question.
I've written Viso add-in in C#, it's name, for example, "VisioProject1".
This add-in have class, for ex. "Class1" with
function, for ex., "MenuItemClick" to handle user-defined menu items clicks.
I've created user defined menu with some items (not inmortant - pop-up or
built in) using this approach:
if (objShape.get_SectionExists((
short )visio.VisSectionIndices.visSectionAction, 0) == 0)

objShape.AddSection(( short )visio.VisSectionIndices.visSectionAction);

objSection = objShape.get_Section((
short )visio.VisSectionIndices.visSectionAction);

shRowIdx = objShape.AddRow(
(short)visio.VisSectionIndices.visSectionAction, 0,
(short)visio.VisRowIndices.visRowAction );

objRow = objSection[ shRowIdx ];

objCell = objRow[ visio.VisCellIndices.visActionMenu ];

objCell.FormulaU = "\"%&User-defined action\"";

objCell = objRow[ visio.VisCellIndices.visActionBeginGroup ];

objCell.FormulaU = "TRUE";

objCell = objRow[ visio.VisCellIndices.visActionTagName ];

objCell.FormulaU = "\"UserMenu\"";



So, question here: what I must specify for the Action cell
(visio.VisCellIndices.visActionAction) to call my handler "MenuItemClick"
inside my add-in?



Any help with example will be greatly appreciated.
 
S

shashi behari

i've never tried it before, preferring to use AddAdvise or SmartTags instead,
but one thing VBA programmers use alot in the Action Formula cell is

=RUNADDON("Method")

so you could probably do something like:
RUNADDON("VisioProject1.Class1.MenuItemClick")

i have no idea if this would work or not, im just guessing that would be the
way to do it if you're set on using the Action section for calling other
methods.

The reason i prefer using AddAdvise and SmartTags is they are cleaner, and
easier to debug. so if the Action thing doesn't work for you, try looking
into those other options.
 
Y

Yevgeny Barkovsky

Thank you for quick answer, but can you tell me, how you are use Smart Tags?
Because I couldn't find good example or documentation about Smart Tags - not
in MSDN, nor I-net.
--
Best regards, Yevgeny Barkovsky
(e-mail address removed)
shashi behari said:
i've never tried it before, preferring to use AddAdvise or SmartTags instead,
but one thing VBA programmers use alot in the Action Formula cell is

=RUNADDON("Method")

so you could probably do something like:
RUNADDON("VisioProject1.Class1.MenuItemClick")

i have no idea if this would work or not, im just guessing that would be the
way to do it if you're set on using the Action section for calling other
methods.

The reason i prefer using AddAdvise and SmartTags is they are cleaner, and
easier to debug. so if the Action thing doesn't work for you, try looking
into those other options.



Yevgeny Barkovsky said:
One more newbie question.
I've written Viso add-in in C#, it's name, for example, "VisioProject1".
This add-in have class, for ex. "Class1" with
function, for ex., "MenuItemClick" to handle user-defined menu items clicks.
I've created user defined menu with some items (not inmortant - pop-up or
built in) using this approach:
if (objShape.get_SectionExists((
short )visio.VisSectionIndices.visSectionAction, 0) == 0)

objShape.AddSection(( short )visio.VisSectionIndices.visSectionAction);

objSection = objShape.get_Section((
short )visio.VisSectionIndices.visSectionAction);

shRowIdx = objShape.AddRow(
(short)visio.VisSectionIndices.visSectionAction, 0,
(short)visio.VisRowIndices.visRowAction );

objRow = objSection[ shRowIdx ];

objCell = objRow[ visio.VisCellIndices.visActionMenu ];

objCell.FormulaU = "\"%&User-defined action\"";

objCell = objRow[ visio.VisCellIndices.visActionBeginGroup ];

objCell.FormulaU = "TRUE";

objCell = objRow[ visio.VisCellIndices.visActionTagName ];

objCell.FormulaU = "\"UserMenu\"";



So, question here: what I must specify for the Action cell
(visio.VisCellIndices.visActionAction) to call my handler "MenuItemClick"
inside my add-in?



Any help with example will be greatly appreciated.
 
S

shashi behari

The Visio SDK (2003) has a nice example in the Code Librarian, which is what
i base all my implementations on. in fact the Code Librarian is probably the
best resource for Visio Automation.
link to sdk:
http://www.microsoft.com/downloads/...BD-B0BB-46E7-936A-B8539898D44D&displaylang=en

Yevgeny Barkovsky said:
Thank you for quick answer, but can you tell me, how you are use Smart Tags?
Because I couldn't find good example or documentation about Smart Tags - not
in MSDN, nor I-net.
--
Best regards, Yevgeny Barkovsky
(e-mail address removed)
shashi behari said:
i've never tried it before, preferring to use AddAdvise or SmartTags instead,
but one thing VBA programmers use alot in the Action Formula cell is

=RUNADDON("Method")

so you could probably do something like:
RUNADDON("VisioProject1.Class1.MenuItemClick")

i have no idea if this would work or not, im just guessing that would be the
way to do it if you're set on using the Action section for calling other
methods.

The reason i prefer using AddAdvise and SmartTags is they are cleaner, and
easier to debug. so if the Action thing doesn't work for you, try looking
into those other options.



Yevgeny Barkovsky said:
One more newbie question.
I've written Viso add-in in C#, it's name, for example, "VisioProject1".
This add-in have class, for ex. "Class1" with
function, for ex., "MenuItemClick" to handle user-defined menu items clicks.
I've created user defined menu with some items (not inmortant - pop-up or
built in) using this approach:
if (objShape.get_SectionExists((
short )visio.VisSectionIndices.visSectionAction, 0) == 0)

objShape.AddSection(( short )visio.VisSectionIndices.visSectionAction);

objSection = objShape.get_Section((
short )visio.VisSectionIndices.visSectionAction);

shRowIdx = objShape.AddRow(
(short)visio.VisSectionIndices.visSectionAction, 0,
(short)visio.VisRowIndices.visRowAction );

objRow = objSection[ shRowIdx ];

objCell = objRow[ visio.VisCellIndices.visActionMenu ];

objCell.FormulaU = "\"%&User-defined action\"";

objCell = objRow[ visio.VisCellIndices.visActionBeginGroup ];

objCell.FormulaU = "TRUE";

objCell = objRow[ visio.VisCellIndices.visActionTagName ];

objCell.FormulaU = "\"UserMenu\"";



So, question here: what I must specify for the Action cell
(visio.VisCellIndices.visActionAction) to call my handler "MenuItemClick"
inside my add-in?



Any help with example will be greatly appreciated.
 
Top