
All attempts I have made so far have failed. Capturing KeyDown has a tendancy to make the toggling flicker if the Alt key is pressed too long. Also, the menu toggles if the user trys ALT+Tab or any other Alt key function.
6 Answers, 1 is accepted
Thank you for writing. You should be toggling the menu on key up, not on key down, if you do it on key up, alt + tab/any key will work. Please not that the menu in internet explorer displays/hides on key up. Write again if you have other questions.
Best wishes,
Victor
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.

I am attempting to capture the Alt key, to (un)hide the menu. But I'm not able to capture key up on the Alt key (though I can on other keys).
Thank you for writing. Please send sample code to illustrate exactly what you are doing. I am interested in the way you are listening for incoming key presses. Your menu must be able to process keyboard input which is not directed to it. In order to implement the menu hiding/showing on the alt key, you must implement a message filter somewhere. I am looking forward to your reply.
Greetings,
Victor
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.

In the example Ctrl-Alt-Y works just fine, but Alt-G (for example) reaches the line I have tagged with " //** HERE ** " and (int)Control.ModifierKeys is null. When pressing just Alt, (m.Msg == WM_KEYUP) is never true.
In the form constructer I have:
Application.AddMessageFilter(new MessageFilter(this));
Plus I have this class:
public
class MessageFilter : IMessageFilter
{
private Form FOwner; //instance of the form in which you want to handle this pre-processing
const int WM_KEYUP = 0x101;
public MessageFilter(Form aOwner)
{
FOwner = aOwner;
}
public bool PreFilterMessage(ref Message m)
{
bool ret = true;
if (m.Msg == WM_KEYUP)
{
Keys key = (Keys)(int)m.WParam & Keys.KeyCode;
// example code which does work
if (key == Keys.Y)
{
if ((int)Control.ModifierKeys == ((int)Keys.Control | (int)Keys.Alt))
{
MessageBox.Show("Captured Ctrl-Alt-Y");
}
else
{
ret =
false;
}
}
else
// example code which does not work
{
if ((int)Control.ModifierKeys == ((int)Keys.Alt)) //** HERE **
{
MessageBox.Show("Captured Alt");
}
}
return ret;
}
else
{
return false;
}
}
}

Thank you for the code. The issue is that you have to handle SYSKEYUP and SYSKEYDOWN notifications in order to properly handle the alt press (and the F10 key if you need to). You can use a boolean value to determine if the alt key is being held down. Also in this article you can see than you can look at the 30th bit of the lParam in order to determine whether the key is pressed for the first time (you can use that to avoid constant repetition of code due to the SYSKEYDOWN repeatedly firing). I am suggesting this approach because we are using it in RadMenu and it works really nice.
You can use the file button with the two angle brackets in order to paste code from visual studio. It is positioned second from right to left on the support ticket editor. Write again if you need further assistance.
All the best,
Victor
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.