Why are “TranslateMessage” and “DispatchMessage” separate calls?

前端 未结 4 1504
孤城傲影
孤城傲影 2020-12-15 04:52

Most of the Win32 main loops I\'ve seen are all structured like:

while (GetMessage(&message, NULL, 0, 0) > 0) {
  TranslateMessage(&message);
  Di         


        
4条回答
  •  一向
    一向 (楼主)
    2020-12-15 05:41

    Well to quote an example from the MSDN:

    You can modify a message loop in a variety of ways. For example, you can retrieve messages from the queue without dispatching them to a window. This is useful for applications that post messages not specifying a window. You can also direct GetMessage to search for specific messages, leaving other messages in the queue. This is useful if you must temporarily bypass the usual FIFO order of the message queue.

    You can also possibly avoid calls to Translate message if you don't need to convert keyboard input control codes.

提交回复
热议问题