CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 1999
    Posts
    12

    how do you detect the alt key

    In my app when the user presses the alt key then releases it my custom cursor changes to an arrow and the file pull down menu is waiting for input. If the user again presses the alt key then my apps custom cursor is restored. Other apps (like Photoshop) behave differently. The alt key can be pressed repeatedly with nothing happening. If alt "F" are pressed then you get the file menu. How can I do this?? I have an OnKeyDown handler in my view class but alt key presses neve go there.

    I understand about the &File on the menu, mine works fine. Here is an example of what I am talking about. I am in internet explorer typing into a test box. When I put the mouse arrow in the text box it changes to an I beam cursor. However while the I beam cursor is up if you press the alt key the I beam cursor changes to an arrow. When you press the alt key a second time the cursor will return to an I beam. Apps like Adobe's Photoshop somehow trap the alt key and prevent the system from displaying the arrow cursor. How can I do this also??




  2. #2
    Join Date
    Apr 1999
    Posts
    26

    Re: how do you detect the alt key

    you can try overriding CWinApp::PreTranslateMessage and handling WM_SYSKEYDOWN.


    void YourApp::PreTranslateMessage (MSG* pMsg)
    {
    if (pMsg->message==WM_SYSKEYDOWN)
    {
    int nVirtKey = (int) pMsg->wParam;
    if (nVirtKey==VK_MENU)
    {
    // user hit ALT key; put in your processing
    // here
    return TRUE;
    }
    }
    return CWinApp::PreTranslateMessage (pMsg);

    }




    --chandra


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured