Resetting virtual keys

This is a discussion on Resetting virtual keys within the Windows Programming forums, part of the Platform Specific Boards category; Alright, i'm using virtual keys and GetAsyncKeyState to make a sort of keyboard selectable menu system for a real basic ...

  1. #1
    Registered User
    Join Date
    Aug 2004
    Posts
    5

    Resetting virtual keys

    Alright, i'm using virtual keys and GetAsyncKeyState to make a sort of keyboard selectable menu system for a real basic console app i'm working on. Problem being that i've got a splash screen at the begining that prompts the user to hit enter...so now I need to know how to reset the virtual keys because once the actuall menu opens it's already made a selection (selections are made with the enter key). Here's the code (a lot of it's from this sites FAQ):

    Code:
    ///////////////////////
    int KeyDetect()
    ///////////////////////
    {
      short esc = 0;
    
      while ( !esc )
      {
        esc = GetAsyncKeyState ( VK_ESCAPE );
    
    
        if (GetAsyncKeyState ( VK_UP ) & SHRT_MAX)
          {
          if(CursorY > 5)
             {
             PrevCursorX = CursorX;
             PrevCursorY = CursorY;
             CursorY = CursorY - 1;
             DrawAsterix(CursorX, CursorY);
             DrawBlack(PrevCursorX, PrevCursorY);
             ReturnCursor(0,16);
             }   
          }
    
    
        else if (GetAsyncKeyState ( VK_DOWN ) & SHRT_MAX)
           {
         if(CursorY < 13)
             {
             PrevCursorX = CursorX;
             PrevCursorY = CursorY;
             CursorY = CursorY + 1;
             DrawAsterix(CursorX, CursorY);
             DrawBlack(PrevCursorX, PrevCursorY);
             ReturnCursor(0,16);
             }
           }
         if (GetAsyncKeyState (VK_RETURN) & SHRT_MAX)
           {
           cout <<"YESS!!!";
           }
      }
    Any and all help is appriciated!

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,676
    MSDN >> The GetAsyncKeyState function determines whether a key is up or down at the time the function is called, and whether the key was pressed after a previous call to GetAsyncKeyState.

    I would try just calling GetAsyncKeyState() after the user presses enter at the splash screen.

    I would also question your use of GetAsyncKeyState() as apposed to a blocking input call like _getch().

    gg

  3. #3
    Registered User
    Join Date
    Aug 2004
    Posts
    5
    Awesome, that did the trick!

    The only reason i'm not using something like _getch() is because I was under the impression that that couldn't read input from the arrow keys. Anyway i'm relatively new to programming and right now i'm more interested in getting to the end product then getting there the easy way. Thanks for the help!

    Walker

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 48
    Last Post: 09-26-2008, 03:45 AM
  2. virtual keys, while loop, movement
    By PHP in forum C++ Programming
    Replies: 3
    Last Post: 12-24-2002, 01:57 PM
  3. Virtual Keys :: MFC
    By kuphryn in forum C++ Programming
    Replies: 1
    Last Post: 03-17-2002, 02:39 PM
  4. C++ XML Class
    By edwardtisdale in forum C++ Programming
    Replies: 0
    Last Post: 12-10-2001, 10:14 PM
  5. Exporting Object Hierarchies from a DLL
    By andy668 in forum C++ Programming
    Replies: 0
    Last Post: 10-20-2001, 01:26 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21