捕捉窗口调整大小

Ran*_*own 5 c++ windows events winapi window

我试图在调整窗口大小时调整图形设备缓冲区的大小,但我没有运气检测到该事件。

这是 C++ Windows 编程。我试过:

            while(WM_QUIT != msg.message){
                if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)){
                    switch(msg.message){
                    case WM_SIZE:
                        return; //<-- If the program closes because of this return, then I know I found the right statements.
                    }
                    //TranslateMessage(&msg);
                    //DispatchMessage(&msg);
                }else{
                    poly.setConstantBuffer(space.getCamera());
                    poly.draw(iSize);

                    graphics.render();
                }
            }
Run Code Online (Sandbox Code Playgroud)

它没有返回,所以这意味着这是不正确的。捕获调整大小事件的正确方法是什么?

Ray*_*hen 3

您应该在窗口过程中处理消息,而不是在消息循环中。PeekMessage不返回已发送的消息,并且WM_SIZE是已发送的消息。