关于GDI+双缓存画图,该如何处理

关于GDI+双缓存画图
GDI+双缓存画图是这样用吗,有什么问题吗?

出现现象:发现有时会画不出来。重启软件也是,不知何解?概率3%左右。


void CDlgMain::OnPaint() //CDlgMain为对话框
{
CPaintDC dc(this); // device context for painting

...
PageDraw();
...




void CDlgMain::PageDraw()
{
。。。
CRect rect;
GetClientRect(&rect);
int ndrawwidth=rect.Width()-m_nDrawstartpos-m_nbottombtwidth;//画图区域宽度

m_ngridShowcount=ndrawwidth/m_ngridpels;
m_nscaleShowcount=m_ngridShowcount*4;
if( m_ngridShowcount == 0 )return;
  m_nPagecount=m_ngridcount/m_ngridShowcount;
if( m_ngridcount%m_ngridShowcount != 0 )
{
m_nPagecount=m_nPagecount+1;
}

if (m_nPagecount == 0)
{
m_nPagecount = 1;
}


  int nstartpos=rect.left + m_nDrawstartpos;
int nendpos=nstartpos+ndrawwidth;
  int ntoppos=rect.top+(rect.Height() - m_nButtonDown)+5;
int nbottompos= ntoppos+20;

m_nendgrid =m_nstartgrid+m_ngridShowcount-1;//结束格子

m_rtgrid.top=ntoppos-3;
m_rtgrid.left=nstartpos;
m_rtgrid.bottom=m_rtgrid.top+nbottompos-ntoppos+6;

Bitmap bitmap( rect.Width(),rect.Height() );  
  Graphics myGraphics(&bitmap);  
myGraphics.SetSmoothingMode(SmoothingModeAntiAlias);
//--------------------------背景色-------------------------------------
Rect rtback(m_rtgrid.left-3,m_rtgrid.top-2,m_rtgrid.Width()+4,m_rtgrid.Height()+6);
LinearGradientBrush Brush(
Point(0, rtback.Y-1),
Point(0, rtback.GetBottom()),
g_ObjUiColorData.m_ClrDlgTopMainBack4,  
g_ObjUiColorData.m_ClrDlgTopMainBack5); 
myGraphics.FillRectangle(&Brush,rtback) ;
。。。。。。
//--------------------
CDC *pdc=this->GetDC(); 
Graphics graphicsDisplay(pdc->GetSafeHdc());  
  Status bsu=graphicsDisplay.DrawImage(&bitmap,rect.left,rect.top,rect.Width(),rect.Height());
// ReleaseDC(pdc); 源方式
graphicsDisplay.ReleaseHDC( pdc->GetSafeHdc() ); //这个地方要这样释放

}

------解决方案--------------------
// ReleaseDC(pdc); 源方式

这行干嘛要注释掉?
资源不释放会出错。
------解决方案--------------------
前面有paint dc,干嘛还要Getdc? 直接当作参数传进来用就行了。。。

------解决方案--------------------
void PageDraw(CDC& dc)

------解决方案--------------------
探讨

void PageDraw(CDC& dc)