http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/b688fe19-8517-473e-9183-83289f650281
Several things happen behind the scenes with CPaintDC. Its constructor calls BeginPaint, which issues an erase background message. So creating two CPaintDC causes interference between them. You can read about the BeginPaint/EndPaint APIs for more understanding of erasing and clipping.
If you want to paint in derived classes and base classes do it the way MFC does with CView. Create the CPaintDC only one time and place and pass it by reference to descendant classes using something like OnDraw(CDC* pDC)
本文详细解释了CPaintDC在MFC应用程序中的工作原理及注意事项。创建CPaintDC时会调用BeginPaint并发送背景擦除消息,因此在同一时刻创建多个CPaintDC可能会导致互相干扰。建议遵循MFC的CView类实现方式,在派生类中通过传递CPaintDC的引用进行绘图。
2289

被折叠的 条评论
为什么被折叠?



