We have a scenario where we are exposing a set of WinForms UserControls
via COM to a Legacy VB6 application. We have 3 different controls which have a MenuStrip
on it that has the Control + F shortcut key mapped to a menu item which invokes a control specific find items dialog when the shortcut is entered. When we try testing this code in our WinForms shell the appropriate dialog (the one hosted in开发者_JAVA技巧 the active MdiChild
) pops up when all 3 controls exist, but in the VB6 host the wrong dialog usually appears (it seems to always be the dialog for the first control which was created).
I'm fairly certain this has something to do with message pumps and all, but I can't seem to figure out how to ensure that the proper ToolStripMenuItem
is getting invoked when we enter the shortcut key.
I know the option of using a global/singleton ShortcutKey
manager/service that overrides ProcessCmdKey
is a possibility, but that would be the last resort we want to fall back on. I just get a feeling that a message pump needs to be started.
This may be inappropriate to your needs. And it might only apply to VB6 specifically. But have you considered having VB6 use the standard menus, and just have it hold onto the keyboard shortcuts, and trigger things appropriately? You could then simply hide the individual menus (but they should still fire their events).
精彩评论