CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: WM_SYSKEYUP not rcvd after Alt

  1. #1
    Join Date
    Sep 2007
    Posts
    2

    WM_SYSKEYUP not rcvd after Alt

    I write and sell a 3D CAD/sim program that I started on VC5 and VC6. Recently, I decided to upgrade to VS2005. I have noted a new behavior in the version compiled by VS2005: both the Alt key and F10 move the input focus to the main menu bar. In the case of the Alt key, this happens when you release the key.

    My app has been using the Alt key as a modifier to mouse input for manipulating the objects in the drawing. "Snap to endpoint" is one of the uses of the Alt key, for example, so I need to handle it fully.

    When compiled under either VC6 or VS2005, the current view receives the WM_SYSKEYDOWN event for the Alt key. However, the current view only sees the VM_SYSKEYUP for the Alt key when compiled under VC6... under VS2005, the event never gets passed to the view. Instead, when the Alt key is released, focus moves to the menu.

    I have searched numerous references to this problem here and elsewhere on the web (a similar situation exists regarding the F10 key, which was also freely available for many years). The only solution I've found is using SetWindowsHookEx(), which I would prefer to avoid.

    I believe the means to easily handle both Alt and F10 are available for two reasons: (1) VS2005 still uses F10 for "Step Over", and (2) compiling my program under VC6, Alt and F10 behave typically, regardless of what version of Windows is running.

    So... the specific question of this post is: does anyone know of a way handle the WM_SYSKEYUP message for the Alt key in a view, or main frame, or any command target in the program when using VS2005?
    Last edited by TrainMan; September 11th, 2007 at 01:25 PM.

  2. #2
    Join Date
    Aug 2007
    Location
    Farnborough, Hants, UK
    Posts
    45

    Re: WM_SYSKEYUP not rcvd after Alt

    I can't answer your question directly, but have you considered using GetAsyncKeyState() at the point when the action (mouse click or other keypress) takes place to see if the <Alt> key is down or has been pressed since you last checked? I believe this technique would not suffer because of the change in behaviour.

  3. #3
    Join Date
    Sep 2007
    Posts
    2

    Re: WM_SYSKEYUP not rcvd after Alt

    Quote Originally Posted by JTeagle
    ...have you considered using GetAsyncKeyState() at the point when the action (mouse click or other keypress) takes place to see if the <Alt> key is down or has been pressed since you last checked?
    Thank you for the suggestion. I could use GetAsyncKeyState() to see if the Alt key is not depressed and the menu bar has the focus, then grab the focus back. It is workable without a hook, but I'd still like to find a clean method.

    I think I should look at the CREATESTRUCT of the main frame window under VC6 and VS2005 and see if there are any new flags set that might prove useful.

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)