I would like to add shortcuts to the MenuItems in my ContextMenu. I am using this code:
mnuContextMenu = new ContextMenu();
saveMenuItem = new MenuItem("Speichern", SaveFile, Shortcut.CtrlS);
mnuContextMenu.MenuItems.Add(saveMenuItem);
The Shortcut is even shown inside the ContextMenu, but it does not respond when i am pressing the keys.
Anybody has an idea why?
I solved this problem............. with the code below...
using System; using System.Windows.Forms;
namespace MyApp { public class Program : Form { private const int WM_HOTKEY = 0x0312; [System.Runtime.InteropServices.DllImport("user32.dll")] private static extern bool RegisterHotKey(IntPtr hWnd, int id, int fsModifiers, int vk);
}