Thread: WM_KEYDOWN has a delay....

  1. #1
    Registered User
    Join Date
    Jul 2005

    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.

    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:
                return 0;
            case VK_LEFT:
                 return 0;
            case VK_RIGHT:
                 if (x>0)
                 return 0;
            case VK_UP:
                 return 0;
            case VK_DOWN:
                 if (y>0)
                 return 0;
            return 0;
            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

    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 04:48 AM.

  2. #2
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Manassas, VA USA
    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 08: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, 02:59 PM
  2. temperature sensors
    By danko in forum C Programming
    Replies: 22
    Last Post: 07-10-2007, 07:26 PM
  3. Networking (queuing delay, avg packet loss)
    By spoon_ in forum A Brief History of
    Replies: 0
    Last Post: 09-05-2005, 11:23 AM
  4. 2-3 Second delay with alarm()
    By Longie in forum C Programming
    Replies: 11
    Last Post: 06-20-2004, 08:46 PM
  5. Delay
    By CanadianOutlaw in forum C++ Programming
    Replies: 4
    Last Post: 09-13-2001, 06:28 AM