Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alt keys and tab don't work in Windows Forms opened from a WPF application

I have lots of old Windows Forms applications that will eventually be ported to WPF (it is a large application so it can't be done in one sprint), and I have started the process by creating a main menu in WPF. The Windows Forms applications are separate windows opened from this menu.

The Windows Forms applications are opening and working without any problems except the issues I am having with the shortcut and Tab keys. The tab key is not moving focus to the next control, and the Alt key to trigger the &Search button no longer works.

What am I doing wrong?

like image 504
Franchesca Avatar asked Jan 31 '12 17:01

Franchesca


1 Answers

A partial solution I discovered is to call this from your WPF constructor: System.Windows.Forms.Integration.WindowsFormsHost.EnableWindowsFormsInterop(); (You need to reference the dll WindowsFormsIntegration.dll)

I say partial because not all key strokes function as expected. Eg, seems to work okay for simple forms.

See this:
http://msdn.microsoft.com/en-us/library/system.windows.forms.integration.windowsformshost.enablewindowsformsinterop(v=vs.100).aspx

like image 97
Gary Huckabone Avatar answered Oct 19 '22 21:10

Gary Huckabone