• <i id='L78x1'><tr id='L78x1'><dt id='L78x1'><q id='L78x1'><span id='L78x1'><b id='L78x1'><form id='L78x1'><ins id='L78x1'></ins><ul id='L78x1'></ul><sub id='L78x1'></sub></form><legend id='L78x1'></legend><bdo id='L78x1'><pre id='L78x1'><center id='L78x1'></center></pre></bdo></b><th id='L78x1'></th></span></q></dt></tr></i><div id='L78x1'><tfoot id='L78x1'></tfoot><dl id='L78x1'><fieldset id='L78x1'></fieldset></dl></div>

  • <tfoot id='L78x1'></tfoot><legend id='L78x1'><style id='L78x1'><dir id='L78x1'><q id='L78x1'></q></dir></style></legend>

      • <bdo id='L78x1'></bdo><ul id='L78x1'></ul>

      <small id='L78x1'></small><noframes id='L78x1'>

      1. 键盘输入Win32 消息循环

        时间:2023-08-02
          • <bdo id='qwoZA'></bdo><ul id='qwoZA'></ul>

              <i id='qwoZA'><tr id='qwoZA'><dt id='qwoZA'><q id='qwoZA'><span id='qwoZA'><b id='qwoZA'><form id='qwoZA'><ins id='qwoZA'></ins><ul id='qwoZA'></ul><sub id='qwoZA'></sub></form><legend id='qwoZA'></legend><bdo id='qwoZA'><pre id='qwoZA'><center id='qwoZA'></center></pre></bdo></b><th id='qwoZA'></th></span></q></dt></tr></i><div id='qwoZA'><tfoot id='qwoZA'></tfoot><dl id='qwoZA'><fieldset id='qwoZA'></fieldset></dl></div>

              <small id='qwoZA'></small><noframes id='qwoZA'>

            1. <tfoot id='qwoZA'></tfoot>
              <legend id='qwoZA'><style id='qwoZA'><dir id='qwoZA'><q id='qwoZA'></q></dir></style></legend>

                  <tbody id='qwoZA'></tbody>

                • 本文介绍了键盘输入Win32 消息循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  如何处理 Windows 消息循环中的按键和按键事件?我需要能够调用两个函数 OnKeyUp(char c);OnKeyDown(char c);.

                  How do I handle key presses and key up events in the windows message loop? I need to be able to call two functions OnKeyUp(char c); and OnKeyDown(char c);.

                  我从谷歌搜索中发现的当前文献让我对 WM_CHAR 或 WM_KEYUP 和 WM_KEYDOWN 感到困惑,并且通常针对 PDA 或托管代码,而我使用的是 C++.

                  Current literature I've found from googling has lead me to confusion over WM_CHAR or WM_KEYUP and WM_KEYDOWN, and is normally targeted at PDA or Managed code, whereas I'm using C++.

                  推荐答案

                  使用char c = MapVirtualKey(param,MAPVK_VK_TO_CHAR);将虚拟键码转换为char,并处理WM_KEYUP和WM_KEYDOWN及其wParams.

                  Use char c = MapVirtualKey(param,MAPVK_VK_TO_CHAR); to convert virtual key codes to char, and process WM_KEYUP and WM_KEYDOWN and their wParams.

                  if (PeekMessage (&mssg, hwnd, 0, 0, PM_REMOVE))
                  {
                      switch (mssg.message)
                      {
                          case WM_QUIT:
                              PostQuitMessage (0);
                              notdone = false;
                              quit = true;
                              break;
                  
                          case WM_KEYDOWN:
                              WPARAM param = mssg.wParam;
                              char c = MapVirtualKey (param, MAPVK_VK_TO_CHAR);
                              this->p->Input ()->Keyboard ()->Listeners ()->OnKeyDown (c);
                              break;
                  
                          case WM_KEYUP:
                              WPARAM param = mssg.wParam;
                              char c = MapVirtualKey (param, MAPVK_VK_TO_CHAR);
                              this->p->Input ()->Keyboard ()->Listeners ()->OnKeyUp (c);
                              break;
                      }
                      // dispatch the message
                      TranslateMessage (&mssg);
                      DispatchMessage (&mssg);
                  }
                  

                  这篇关于键盘输入Win32 消息循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何使用 CreateProcess 将输出重定向到文件? 下一篇:关闭 C++ 控制台应用程序时会发生什么

                  相关文章

                  最新文章

                    <bdo id='rmgG8'></bdo><ul id='rmgG8'></ul>
                  <legend id='rmgG8'><style id='rmgG8'><dir id='rmgG8'><q id='rmgG8'></q></dir></style></legend>
                • <i id='rmgG8'><tr id='rmgG8'><dt id='rmgG8'><q id='rmgG8'><span id='rmgG8'><b id='rmgG8'><form id='rmgG8'><ins id='rmgG8'></ins><ul id='rmgG8'></ul><sub id='rmgG8'></sub></form><legend id='rmgG8'></legend><bdo id='rmgG8'><pre id='rmgG8'><center id='rmgG8'></center></pre></bdo></b><th id='rmgG8'></th></span></q></dt></tr></i><div id='rmgG8'><tfoot id='rmgG8'></tfoot><dl id='rmgG8'><fieldset id='rmgG8'></fieldset></dl></div>

                  1. <tfoot id='rmgG8'></tfoot>

                    <small id='rmgG8'></small><noframes id='rmgG8'>