第一次画出来时lpbuf中没有存入数据,刷新一次就有数据了,怎么回事?在内存DC上画图到底改变了什么?能直接把数据传给Hbitmap,或者lpbuf吗?  
void  CMyDrawView::OnDraw(CDC*  pDC)  
{  
           CMyDrawDoc*  pDoc  =  GetDocument();  
           ASSERT_VALID(pDoc);  
           //  TODO:  add  draw  code  for  native  data  here  
           HBITMAP  oldbitmap;  
           CDC  memDc;  
           int  i,  nMaxNum  =  0;  
           int  ntleftx,  nttopy,  nleftx,  ntopy,  ntrightx,  ntbottomy,  nrightx,  nbottomy,  nwidth,  nheight;  
           ntrightx  =  ntbottomy  =  nrightx  =nbottomy  =  nwidth  =  nheight  =  0;  
           ntleftx  =  nttopy  =  nleftx  =  ntopy  =  2147483647;  
             
           if(pDoc->m_hbitmap  ==  NULL)  
                       return;  
             
           memDc.CreateCompatibleDC(pDC);  
           oldbitmap  =  (HBITMAP)memDc.SelectObject(pDoc->m_hbitmap);                          
             
           if(pDoc->m_iDrawType  !=  0  )  
           {  
                       for(i  =  0;  i  <  m_ptrarray.GetSize();  i++)  
                       {  
                                   CPen      pen;  
                                   CBrush  Brush;  
                                   pen.CreatePen(PS_SOLID,2,((CGraph*)m_ptrarray.GetAt(i))->m_color);    
                                   Brush.CreateSolidBrush(((CGraph*)m_ptrarray.GetAt(i))->m_color);  
                                   memDc.SelectObject(&pen);    
                                   memDc.SelectObject(&Brush);  
                                   switch(((CGraph*)m_ptrarray.GetAt(i))->m_iDrawType)  
                                   {                                                  
                                   case  DRAW_LINE:  
                                               memDc.MoveTo(((CGraph*)m_ptrarray.GetAt(i))->m_ptbegin.x,  ((CGraph*)m_ptrarray.GetAt(i))->m_ptbegin.y);  
                                               memDc.LineTo(((CGraph*)m_ptrarray.GetAt(i))->m_ptend.x,    ((CGraph*)m_ptrarray.GetAt(i))->m_ptend.y);  
                                               break;  
                                   case  DRAW_RECTANGLE:  
                                               memDc.Rectangle(((CGraph*)m_ptrarray.GetAt(i))->m_ptbegin.x,  ((CGraph*)m_ptrarray.GetAt(i))->m_ptbegin.y,  
                                                           ((CGraph*)m_ptrarray.GetAt(i))->m_ptend.x,  ((CGraph*)m_ptrarray.GetAt(i))->m_ptend.y);  
                                               break;  
                                   case  DRAW_ELLIPSE:  
                                               memDc.Ellipse(((CGraph*)m_ptrarray.GetAt(i))->m_ptbegin.x,  ((CGraph*)m_ptrarray.GetAt(i))->m_ptbegin.y,  
                                                           ((CGraph*)m_ptrarray.GetAt(i))->m_ptend.x,  ((CGraph*)m_ptrarray.GetAt(i))->m_ptend.y);  
                                               break;  
                                   default:  
                                               break;  
                                   }  
                       }  
           }  
             
           StretchBlt(pDC->GetSafeHdc(),  0,  0,  pDoc->m_nwidth*pDoc->m_iZoomFactor/100,  
                       pDoc->m_nheight*pDoc->m_iZoomFactor/100,  memDc.GetSafeHdc(),  0,  0,    
                       pDoc->m_nwidth,  pDoc->m_nheight,  SRCCOPY);  
             
           if(pDoc->m_nwidth  >  0  &&  pDoc->m_nheight  >  0  &&  pDoc->m_hbitmap  !=  NULL)  
           {  
                       SetScrollSizes(MM_TEXT  ,CSize(pDoc->m_nwidth*pDoc->m_iZoomFactor/100,  
                                   pDoc->m_nheight*pDoc->m_iZoomFactor/100));  
           }  
             
           memDc.SelectObject(oldbitmap);  
                 memDc.DeleteDC();  
}