新建了一个win32 console Application 程序

将其默认主循环代码
“while (GetMessage(&msg, NULL, 0, 0))”
改为
“while(msg.message != WM_QUIT)”


编译没有error,但有“warning C4700: uninitialized local variable 'msg' used”

F5出现提示:“Run-Time Check Failure #3 - The variable 'msg' is being used without being initialized.”

msg需要怎样初始化?

答案:
1. 在进入while循环之前,先GetMessage(&msg,NULL,NULL,NULL);一次,让msg初始化。在循环体中应该再调用GetMessage或PeekMessage,否则就真成了死循环了。
2.
MSG msg;
msg.message = WM_NULL;
PeekMessage(&msg, NULL, 0U, 0U, PM_NOREMOVE);



相关文章:

  • 2021-11-03
  • 2022-01-15
  • 2022-12-23
  • 2022-01-23
  • 2021-08-11
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-06
  • 2021-08-30
  • 2021-04-05
  • 2021-07-28
  • 2021-07-14
  • 2022-12-23
  • 2021-12-12
相关资源
相似解决方案