Win32: My Application freezes while the user resizes the window

前端 未结 4 835
执笔经年
执笔经年 2020-12-15 00:13

I write a win32 application. I implemented the message loop myself like this:

     bool programcontinue = true;
     while(programcontinue)
     {
                   


        
4条回答
  •  北荒
    北荒 (楼主)
    2020-12-15 01:01

    During resize Windows sends quite a few messages to your program. I have not proved this, but the behavior you describe is familiar. I'd suggest to call your function IdleProcess() also within the while(...) loop for certain events such as WM_SIZING which your application will receive frequently during window resizing:

     bool programcontinue = true;
     while(programcontinue)
     {
              while (PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE))
              {
                       TranslateMessage(&Msg);
                       DispatchMessage(&Msg);
                       if(Msg.message == WM_SIZING)
                           IdleProcess();
              }
    
              IdleProcess();
     }
    

    Be aware though that this assumes, that IdleProcess() does not create or consume any events. If thats the case, things get much more complicated.

提交回复
热议问题