1

I am struggling with implementing the basic shortcuts for my vsto Outlook add-in. However I need at the very least to be able to paste text into a combobox that is in a small forms window that appears in the preview pane of the mail.

I was able to implement the paste function with only 'ctrl' or only 'v' pressed I have tried everything I found on the internet and even got the functionality working in a test windows forms project with:

private void comboBox1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Control && e.KeyCode == Keys.V)
            {
                comboBox1.Text = "success";
            }
        }

However when I try the same code in the outlook vsto project this does simply not work. Did anybody have the same or a similar problem? How did you fix it?

Thank you for your help.

Kili
  • 27
  • 5

2 Answers2

0

The Combobox control from the Fluent UI doesn't provide the KeyDown event. The best what you can do is to implement ribbon callbacks: getText and onChange.

The onChange callback is called when the value in the edit box is changed and committed by the user.

The signature of the callback should like the following one:

C#: void OnChange(IRibbonControl control, string text)
VBA: Sub OnChange(control As IRibbonControl, text As String)
C++: HRESULT OnChange([in] IRibbonControl *pControl, [in] BSTR *pbstrText)
Visual Basic: Sub OnChange(control As IRibbonControl, text As String)

You can read more about the Fluent UI (aka Ribbon UI) in the following series of articles:

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
  • Thanks for the quick response. However I generated the eventhandler with the event properties from visual studio.. Also I was able to implement the paste function with only the control key or only the 'v' key pressed. Also I don't use the ribbon, but I have a small forms window in the preview pane of the mail. I will edit this info in my post, sorry for the missing info. – Kili Nov 04 '19 at 10:08
  • The OP means a combo box on a form, not on a ribbon. – Dmitry Streblechenko Nov 04 '19 at 15:23
0

Outlook eats some key strokes. The only way I could work around that is by installing a keyboard hook (SetWindowsHookExW(WH_GETMESSAGE,...)) and forwarding the appropriate messages directly to my controls.

Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78