views:

166

answers:

0

I'm handling WM_CHAR in a MessageFilter written in C#. I need to interpret the key that was pressed along with whether the ctrl or alt keys were pressed at the same time. So far, I've got this:

case WM_CHAR:
    {
        bool control = (Control.ModifierKeys & Keys.Control) != 0;
        bool alt = (Control.ModifierKeys & Keys.Alt) != 0;

        char c = (char)msg.WParam;

        HandleShortcut(c,control,alt);
    }

If I press 'f' or 'alt-f', I get the value of c in the snippet above to be the character 'f'. However, if ctrl is down, I get a different value for c. I get the decimal value 6 instead.

I really need to get an 'f' regardless of whether the ctrl key was down. Do you know how I can get this?

I've seen this related article, but I don't think I can go down this route because I don't want to mess up how the key gets translated because other parts of the application might break if I start messing about with how keys get translated.

http://www.gamedev.net/community/forums/topic.asp?topic_id=470716

Any help would be greatly appreciated. Thanks.