January 27th, 2013, 06:46 AM
How to create an image buffer in MFC
I'm new to codeguru and beginner with MFC.
Can anyone please explain, or point out to an internet resource that explains how to create, initialize, and maintain a memory device context that works as a local buffer for images? The idea is to maintain some large images in local DCs and bitmaps, and only bitblt them to screen in OnDraw().
What I did so far was was to define CDC and CBitmap objects as members of my View class, and then tried to initialize them with the sequence that begins at "// Initialize buffer". I placed that sequence in either OnInitialUpdate, or PreCreateWindow, or OnPrepareDC, or the view constructor, to no avail. The code always crashes in OnDraw, and I've noticed that the m_hDC member of myDevice is zero at that point.
Obviously, the initialization is wrong and MFC does (too many) things in the background which I'm not aware of.... My question was where can I read about that?
class CMyView : public CScrollView
// Initialize buffer
CDC* pdc = GetDC();
oldbmp = myDevice.SelectObject(&bmp);
// Initialize buffer - end
Tags for this Thread
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!