Suppress keyboard shortcuts

R

Roger

Does anyone know anyway of stopping certain keyboard shortcuts being
processed by the Visio Drawing Control? For example, I'd rather have F1
access the help system for my app rather than the Visio help system and I'd
like to direct Ctrl+F to my application rather than to the Visio find dialog.
I've already tried many different alternatives including setting
cancelDefault in the keydown and keyup events.

Many thanks
Roger Billsdon
 
C

Chris [Visio MVP]

This sub gets rid of ALL of the keyboard shortcuts. Perhaps you'll be able
to figure out exactly which one is "F1"

Private Sub m_removeAllKeyboardShortcuts(ByRef visDoc As Visio.Document)

'// Get a the ui object:

Dim ui As Visio.UIObject = visDoc.Application.BuiltInMenus.Clone '.Clone

Dim accTbl As Visio.AccelTable

'// For each menu context:

For iCtx As Integer = 0 To ui.AccelTables.Count - 1

accTbl = ui.AccelTables.Item(iCtx)

Debug.WriteLine("----" & accTbl.TableName & "----")

'// For each accel item in the context:

For i As Integer = accTbl.AccelItems.Count - 1 To 1 Step -1

accTbl.AccelItems.Item(i).Delete()

Next

Next

visDoc.SetCustomMenus(ui)

End Sub
 
R

Roger

Hello Chris
Many thanks for the suggestion, but unfortunately this approach doesn't work
with the Visio Drawing Control. I've also tried many variations on this theme
and manipulating the commandbars.

Among my other ideas was overriding the ProcessCmdKey, PreProcessMessage and
other functions for the Visio Drawing Control and the containing form. I
thought this might provide a means of trapping short-cut keys before they
were processed by the Visio Drawing Control. But no success.

I found a discussion between JuneTheSecond and xargon dated April 2005 on
Visio Drawing Control keypress event handling problems, but no solution was
reported.

Any further comments would be very welcome.
Many thanks
Roger Billsdon
 
C

Chris [Visio MVP]

I did this explicitly WITH the Visio control.


Roger said:
Hello Chris
Many thanks for the suggestion, but unfortunately this approach doesn't
work
with the Visio Drawing Control. I've also tried many variations on this
theme
and manipulating the commandbars.

Among my other ideas was overriding the ProcessCmdKey, PreProcessMessage
and
other functions for the Visio Drawing Control and the containing form. I
thought this might provide a means of trapping short-cut keys before they
were processed by the Visio Drawing Control. But no success.

I found a discussion between JuneTheSecond and xargon dated April 2005 on
Visio Drawing Control keypress event handling problems, but no solution
was
reported.

Any further comments would be very welcome.
Many thanks
Roger Billsdon
 
R

Roger

Chris
My sincere apologies, my version must have had some subtle difference
because I've tried your version again and it works perfectly.

Checking the accelerator item's Alt, Shift and Control properties plus
comparing the Key property with the Keys enumeration enables you to find the
short-cut keys you specifically need to disable. An alternative would be to
check the CmdNum property.
Many thanks
Roger Billsdon
 

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