简体   繁体   English

WM_KEYDOWN没有回应

[英]WM_KEYDOWN doesn't response

In case WM_KEYDOWN has a messagebox() in order to understand the functionality of this case. 如果WM_KEYDOWN具有messagebox()以便了解这种情况的功能。

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. 我尝试从键盘和调试器插入一些字母而不会出现WM_KEYDOWN情况时进行调试。

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. MessageBox()显示一个弹出对话框,然后运行自己的模式消息循环为该对话框的消息提供服务,直到关闭为止。 While the dialog is active, your keystrokes are going to that dialog and not to the window that your WndProc() belongs to. 对话框处于活动状态时,您的击键将转到该对话框,而不是WndProc()所属的窗口。 That is why you are not getting more WM_KEYDOWN messages. 这就是为什么您没有收到更多WM_KEYDOWN消息的原因。 You should not be using MessageBox() as a debugging tool for UI messages, because it changes the flow of UI messages. 您不应该将MessageBox()用作UI消息的调试工具,因为它会更改UI消息的流程。 Use OutputDebugString() instead. 使用OutputDebugString()代替。 That way, your debugger (or an external viewer like SysInternals DebugView) can display your debug messages without affecting your UI's behavior. 这样,调试器(或SysInternals DebugView等外部查看器)可以显示调试消息,而不会影响UI的行为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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