CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 1999
    Location
    Nepal
    Posts
    540

    Detecting the Alt state

    In my application, I would like to change the icon when the user presses Alt (Alt only, no other character, so i cannot use the KeyDown Event). How do I do it?

    I plan to use a global boolean variable AltPressed and a timer that ticks every 100 ms, and use GetKeyState in each timer tick to detect the Alt State.

    Is there a neater solution?


  2. #2
    Join Date
    Dec 2000
    Location
    Los Angeles, CA
    Posts
    34

    Re: Detecting the Alt state

    Another choice would be to make a keyboard hook, so that all key events are seen by the hook. That way you can ignore all non-Alt key events and then toggle your global variable on the Alt events. I have recently been looking into keyboard hooks for another project and I have a couple of good sites to check out depending on what you want to do.

    If you want a local hook [only recieves keystrokes from within your application], take a look here:
    http://vbaccelerator.com/codelib/hook/vbalhook.htm

    If you need a system wide hook, I found a neat control that will do it:
    http://www.scottandmichelle.net/scot...mv?codenum=082

    Hope this helps.

    Nathan


  3. #3
    Join Date
    Mar 1999
    Location
    Nepal
    Posts
    540

    Re: Detecting the Alt state

    Thanks,

    And I got hooked onto something else there - the Cool Menu. I was looking for a method to make my menus better.


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