none
Initiate call to OleMenuCommand

    Question

  • Hi, I have the following problem:

    I created an isolated shell program 

    with DataGrid and OleMenuCommand that it's keybinding is 'F4'

    I try to disable the comboBox open event with 'F4' and instead call the OleMenuCommand  that is keybinding is 'F4' ( maybe user changed the keys, so need to check if there is any??).

    So,

    How do I check in the if there is a command with 'F4' key in the WindowPane ? How to call it?

    Thanks.

    Sunday, June 24, 2012 1:16 PM

Answers

  • Are you using WPF or WinForms or Win32 for your toolwindow UI?

    The only way the UI layer (WPF, WinForms, etc..) would get the key in such a way as to possibly use it for interaction with a combo box is if VS didn't translate it into a command (we run the message pump so we see all messages before WPF/WinForms/Win32 UI would).

    It sounds like either:

    A)  You are using WinForms for your UI, WindowPane (from MPF) for your toolwindow pane and you have not overridden PreProcessMessage to prevent the keystroke from being passed on the WinForms.

    B)  You have overridden PreProcessMessage to explicitly pass the message on yourself.

    C)  Your command is not reporting as enabled thus the keybinding matchup fails and we pass the message on the the UI framework.

    Ryan

    Monday, June 25, 2012 3:44 PM
    Moderator

All replies

  • F4 is, by default, bound to the command that shows the properties window, at least at the global scope. For it to be triggering a combo open/close it implies VS did not find a keybinding that matched against an enabled command.  It would be necessary to know at least the following for your situation:

    1:  How are you declaring your command (VSCT I assume) and associating the keybinding with it?

    2:  What is the scope of the keybinding (global, tied to a specific toolwindow, etc...)?

    Ryan

    Sunday, June 24, 2012 5:32 PM
    Moderator
  • "F4 is, by default, bound to the command that shows the properties window, at least at the global scope"

    Yes, your right, I override it in General.vssettings file under Environment_Group category (as in the export file after changing the keyboard settings)

    "1:  How are you declaring your command (VSCT I assume) and associating the keybinding with it?"

    I declared the command in the VSCT file 

     under <DefaultShortcuts> : 

    <RemoveShortcut Command="View.PropertiesWindow" Scope="Global">F4</RemoveShortcut>

    <Shortcut Command="MyCommand" Scope="Global">F4</Shortcut>

    "2: What is the scope of the keybinding (global, tied to a specific toolwindow, etc...)?"

    The scope is global 

    Moreover, when I removed my declaration the comboBox still steal the F4, the only way I found is to use previewKeyDown in some parent of comboBox,  e.Handled = true and after that call my own method,  in this method I want to run the command which F4 is binded to. 

    Thanks.


    • Edited by Idan2000 Monday, June 25, 2012 7:31 AM
    Monday, June 25, 2012 7:30 AM
  • Are you using WPF or WinForms or Win32 for your toolwindow UI?

    The only way the UI layer (WPF, WinForms, etc..) would get the key in such a way as to possibly use it for interaction with a combo box is if VS didn't translate it into a command (we run the message pump so we see all messages before WPF/WinForms/Win32 UI would).

    It sounds like either:

    A)  You are using WinForms for your UI, WindowPane (from MPF) for your toolwindow pane and you have not overridden PreProcessMessage to prevent the keystroke from being passed on the WinForms.

    B)  You have overridden PreProcessMessage to explicitly pass the message on yourself.

    C)  Your command is not reporting as enabled thus the keybinding matchup fails and we pass the message on the the UI framework.

    Ryan

    Monday, June 25, 2012 3:44 PM
    Moderator
  • Hi julie40,

    I will mark Ryan's reply as answer.

    If it is not the answer you want, please unmark it.

    Best regards,


    Ego [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, July 03, 2012 7:43 AM
    Moderator