I have a dialog with a generic CWnd embedded into it.
I want to allow the user to change the size of the dialog. So here is my method:
This is the OnSize handler in the dialog window
So you see I'm passing the command then to the CWnd and using MoveWindow to change the size of that window.Code:void TilePickerDlg::OnSize(UINT nType, int cx, int cy) { m_wndTileRenderer.MoveWindow(0,0,cx-5,cy-5,true); m_wndTileRenderer.Resize(cx-5,cy-5); CDialog::OnSize(nType, cx, cy); }
My renderer then needs to re-calculate the size of the memory bitmap for the window since I'm using double buffering.
Here is the Resize code:
It is inline which is why the class name is not in front of the function name. So it's a simple, de-select the existing bitmap - which is the MemoryBitmap, detach it, re-create it, and then re-select it into the DC. Then re-calc the scroll extents.Code:void Resize(int cx,int cy) { MemoryDC.SelectObject(MemoryBitmap); MemoryBitmap.Detach(); //Create bitmap MemoryBitmap.CreateCompatibleBitmap(GetDC(),cx,cy); //Select bitmap into DC MemoryDC.SelectObject(MemoryBitmap); CalculateMaxScroll(); }
It works great until the window gets past a certain size and then it acts as if the DC is corrupt. It still draws, but it slows everything down in the editor. All drawing begins to look like slideshows.
Any ideas?



LinkBack URL
About LinkBacks



eleteObject()