Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Catching Window Resize

I'm trying to resize a graphics device buffer when the window is resized, but I have no luck in detecting the event.

This is C++ Windows programming. I tried:

            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();
                }
            }

It is not returning, so that means that is not correct. What is the right way to catch the resize event?

like image 577
Nyaarium Avatar asked Oct 10 '12 03:10

Nyaarium


Video Answer


1 Answers

You should be handling messages in your window procedure, not in the message loop. PeekMessage does not return sent messages, and WM_SIZE is a sent message.

like image 116
Raymond Chen Avatar answered Sep 28 '22 07:09

Raymond Chen