WM_KEYDOWN has a delay....

This is a discussion on WM_KEYDOWN has a delay.... within the C++ Programming forums, part of the General Programming Boards category; ok im playing arround with the open gl example that comes with dev c++, and im making you able to ...

  1. #1
    Registered User
    Join Date
    Jul 2005
    Posts
    11

    WM_KEYDOWN has a delay....

    ok im playing arround with the open gl example that comes with dev c++, and im making you able to change how big the triangle is and how fast it spins.

    Code:
    LRESULT CALLBACK WndProc (HWND hWnd, UINT message,
                              WPARAM wParam, LPARAM lParam)
    {
    
        switch (message)
        {
        case WM_CREATE:
            return 0;
        case WM_CLOSE:
            PostQuitMessage (0);
            return 0;
    
        case WM_DESTROY:
            return 0;
    
        case WM_KEYDOWN:
            switch (wParam)
            {
            case VK_ESCAPE:
                PostQuitMessage(0);
                return 0;
            case VK_LEFT:
                 x++;
                 return 0;
            case VK_RIGHT:
                 if (x>0)
                     x--;
                 return 0;
            case VK_UP:
                 y++;
                 return 0;
            case VK_DOWN:
                 if (y>0)
                     y--;
                 return 0;
            }
            return 0;
    
        default:
            return DefWindowProc (hWnd, message, wParam, lParam);
        }
    }
    when you press any of these it executes once, then waits for a half second or whatever and then carries on executing. like in a word processor. how can i avoid this? thanks

    edit:
    oh yeah, one more thing. is there a site with a comprehensive list of all open gl functions and their parametres and what they do and maybe even how to use them? thanks again
    Last edited by jimjamjahaa; 07-09-2005 at 05:48 AM.

  2. #2
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Location
    Manassas, VA USA
    Posts
    903
    WM_KEYDOWN is sent via the windows message que.. so there may be a delay while your program is handling other messages. Also, keyboard events as far as windows is concerned, are not high-priority messages. Windows will generate keyboard event messages whenever it gets around to it. Try using GetAsyncKeyState(). As the name of the function implies, looks for keyboard input independant from the message que.. and will send keyboard events directly to your windows procedure.
    Last edited by The Brain; 07-09-2005 at 09:39 AM.
    • "Problem Solving C++, The Object of Programming" -Walter Savitch
    • "Data Structures and Other Objects using C++" -Walter Savitch
    • "Assembly Language for Intel-Based Computers" -Kip Irvine
    • "Programming Windows, 5th edition" -Charles Petzold
    • "Visual C++ MFC Programming by Example" -John E. Swanke
    • "Network Programming Windows" -Jones/Ohlund
    • "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
    • "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Regarding delay in the connection
    By byatin in forum Networking/Device Communication
    Replies: 2
    Last Post: 08-19-2008, 03:59 PM
  2. temperature sensors
    By danko in forum C Programming
    Replies: 22
    Last Post: 07-10-2007, 08:26 PM
  3. Networking (queuing delay, avg packet loss)
    By spoon_ in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 09-05-2005, 12:23 PM
  4. 2-3 Second delay with alarm()
    By Longie in forum C Programming
    Replies: 11
    Last Post: 06-20-2004, 09:46 PM
  5. Delay
    By CanadianOutlaw in forum C++ Programming
    Replies: 4
    Last Post: 09-13-2001, 07:28 AM

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