0
votes

I'm working on an ActiveX control which is hosted in MFC and VB6 applications.

This ActiveX contains a WPF control, itself hosted by a WinForms ElementHost, i.e.:

MFC > .NET ActiveX > WinForms ElementHost > WPF UserControl

When an user right-clicks on the control, he must be able to navigate in the contextual menu using the keyboard arrow keys.

If my control has the focus when the right-click occurs, everything works fine.

But if the focus is in the host application when the user right-clicks, keyboard events continue to be sent to the host MFC application.

I tried to call the Focus() method on my WPF control when I detect the right click, but it doesn't work.

Does anybody have an idea ?

Thanks.

1

1 Answers

0
votes

I have found a workaround.

When the PreviewMouseRightButtonDown event occurs on the WPF form, I call the Focus method on the WinForm host control.

I don't really understand why, but this lets users use their keyboards to navigate in the contextual menu.