简体   繁体   中英

WM_KEYDOWN doesn't response

In case WM_KEYDOWN has a messagebox() in order to understand the functionality of this case.

somebody can help me why this case didn't response?

I'm trying to do debugging this while i insert some letter from keyboard and debugger not coming to WM_KEYDOWN case.

Thanks to all!

this is my code:

LRESULT CALLBACK WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
  switch( msg )
  {
  case WM_CREATE:
    break;
  case WM_COMMAND:
    break;
  case WM_KEYDOWN:
    MessageBox(NULL,L"test",L"Information",MB_ICONINFORMATION);
    break;
  case WM_DESTROY:
    // DESTROY WINDOW
    break;
  default:
    return DefWindowProc( hwnd, msg, wParam, lParam );
  }
  return  0;
}

MessageBox() displays a popup dialog and then runs its own modal message loop to service messages for that dialog until it closes. While the dialog is active, your keystrokes are going to that dialog and not to the window that your WndProc() belongs to. That is why you are not getting more WM_KEYDOWN messages. You should not be using MessageBox() as a debugging tool for UI messages, because it changes the flow of UI messages. Use OutputDebugString() instead. That way, your debugger (or an external viewer like SysInternals DebugView) can display your debug messages without affecting your UI's behavior.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM