window resize and updating size of dc's

I have a sprite animation that stores the background of the window it uses and want to know how to check for the window being resized? I have tried onSizing but it only gets called at the end of the program. I would like code to be called when the user drags the window to a new size or uses the maximise or restore buttons.

In the CFrameWnd subclass constructor I use this code to create a memory dc for the entire window:

clientRect is a CRect and paintBuffer is a CDC object, paintBmp is a CBitmap. They are private members of the window class.

I blit things to paintBuffer as needed and then blit that to the window in the OnPaint event. When the window gets resized how do I update the above variables to handle the new size? Do I need to delete and recreate them? If so how exactly?

My sprites depend on paintBuffer being correct due to saving and restoring the background, I will post more about that if I need to.

Okay, you cannot resize a DC.. only you can resize the bitmap associated (selected) with it.. That means, you need to create a new bitmap, bitblit your old bitmap on it, or redraw whole bitmap, using your DC..

AlexFM: I have tried doing what you say but it leads to a crash. I stepped through the code and before the window is shown, it goes to OnSize and deletes the paintBuffer and paintBmp. An assert fails here:

I tried the below. The call stack info is from .Net debugger as it is installed on my system but I am using VC++ 6. Not sure how to get the debugger back to the version 6 one, but if it matters let me know and I'll try and change it.

Introduction:
Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information.
Continuing from the first article about sudoku. There we have designed the application and put a lot of user int…

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.

In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…