F1 keydown for menuitem

  • Thread starter Thread starter B.
  • Start date Start date
B

B.

Each of my menuitem has a help topic. When user selects the menuitem
and press F1, it should pop up the help. However, how can I catch the
F1 keydown event for the menuitem? There is no keydown event for the
menuitem.
 
One way you can do this is to override the form's WndProc and look for
WM_HELP.

protected override void WndProc(ref Message m)
{
if (m.Msg == 0x53) //WM_HELP
{
if (this.filesToolStripMenuItem.Selected)
{
MessageBox.Show(string.Format("F1 pressed {0}",
this.filesToolStripMenuItem.Name));
}
else if (this.filesOpenToolStripMenuItem.Selected)
{
MessageBox.Show(string.Format("F1 pressed {0}",
this.filesOpenToolStripMenuItem.Name));
}
}
base.WndProc(ref m);
}

================
Clay Burch
Syncfusion, Inc.
 
Back
Top