Hello everyone,

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
// ...
	CDC myDevice;
	CBitmap bmp;
	CBitmap *oldbmp;

// Initialize buffer
	CDC* pdc = GetDC();
	oldbmp = myDevice.SelectObject(&bmp);
// Initialize buffer - end

Thank you,