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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top