Archived

This topic is now archived and is closed to further replies.

MFC & solving the repaint problem

This topic is 5049 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am having a devil of a time merging two rather simple concepts. The first can be found in Jeff Prosise "Programming Windows with MFC" Chapter 4 - where he shows how to use a Cwnd sized to the client area of the CFrameWnd so that you don't have to worry about constantly calculating the size of toolbars, dialogbars, menus, etc. when calling GetClientRect. The second concept is using a virtual window (using memory object the same size as your actual window) to solve the "repaint problem" by flipping the virtual window in memory to the actual screen when necessary (emphasized in Schildt's "MFC Programming from the Ground Up" as well as other several books I am sure). This is accomplished by the following code: CClientDC DC (&m_wndView); m_memDC.CreateCompatibleDC (&DC); CBitmap m_bmp; m_bmp.CreateCompatibleBitmap (&DC, maxX, maxY); m_memDC.SelectObject (&m_bmp); In merging these two concepts I am having trouble with assertion errors occurring when other functions write to the vitual window similar to the following example: m_memDC.StretchBlt (0, 0, maxX, maxY, &m_bmpDC, 0, 0, 561, 513, SRCCOPY); I made m_memDC a global variable so that it could be easily accesed by all other functions in the program. I believe the assertion is related to it trying to get a safe handle to the "child" window, but I am not sure. If anyone knows of any tutorials merging these two concepts, it would be greatly appreciated. Thanks in advance. -TG [edited by - Tampa_Gamer on February 20, 2004 11:41:00 PM]

Share this post


Link to post
Share on other sites