Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

tapper

Debug and Release builds behave differently (msvc++6)

This topic is 5422 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m using the following code to translate the virtual key code stored in wParam to the corresponding ascii character and store it in the variable AsciiChar:
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
  if (msg==WM_KEYDOWN)
  {
    unsigned char KeyState[256];
    unsigned short Char;
    unsigned char AsciiChar;

    if (GetKeyboardState(KeyState))
    {
      ToAscii(wParam, NULL, KeyState, &Char, 0);
      AsciiChar = (char) Char;

    //

    // Some code here

    //

    }
  }
}
If the active configuration is set to "Debug" everything works fine. But if I change it to "Release" and try to press the shift key, the value stored in AsciiChar is the previous key pressed (i. e. if I press ''A'' and then the shift key I get another ''A''). Why does GetKeyboardState() return different values on the different builds? I''m kind of new to programming so I have no idea what all the compiler switches does. Maybe someone can help me?

Share this post


Link to post
Share on other sites
Advertisement
For normal keys, you should respond to the WM_CHAR message. WM_KEYDOWN is typically reserved for handling cursor keys and function keys.

I''m not sure why you get different behavior in debug vs release mode, but switching to WM_CHAR should solve your problem.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!