在我的工程中基于CScrollView派生了一个视图类,在这个视图类的OnDraw()函数中我进行绘图(黑色),背景是白色,现在地问题是当我在滚动水平滚动条是,就会
产生一条条白色的竖直的白线,在滚动垂直滚动条就会产生一条条水平的白线,我观察了一下,这些白线都是有窗口客户区的边界处产生的,由于我考虑到屏闪和绘图的效率问题,说以我采用了内存中采用剪取无效区绘图的方式,没有采用全部从绘的方式,我的OnDraw()函数如下:
void CBoatView::OnDraw(CDC* pDC)
{
CDC dc;
CDC* pDrawDC = pDC;
CBitmap bitmap;
CBitmap* pOldBitmap;
CRect client;
pDC->GetClipBox(client);//检取无效区
CRect rect = client;
DocToClient(rect); client=pd->m_ps.rcPaint;//检取无效区
CRect rect = client; ClientToDoc(rect);//转换为设备坐标
if (!pDC->IsPrinting())
{
//创建一个与pDC兼容的内存设备环境 
if (dc.CreateCompatibleDC(pDC))
{
//创建一与pDC兼容的位图
if (bitmap.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height()))
{
OnPrepareDC(&dc, NULL);//使dc与pDC具有同样的映射关系 pDrawDC = &dc; // offset origin more because bitmap is just piece of the whole drawing
dc.OffsetViewportOrg(-rect.left, -rect.top);
pOldBitmap = dc.SelectObject(&bitmap);//将位图选入内存环境
dc.SetBrushOrg(rect.left % 8, rect.top % 8); // might as well clip to the same rectangle
dc.IntersectClipRect(client);
}
}
}
else {//printing
}
if(!pDC->IsPrinting()){

CBrush brush;
if (!brush.CreateSolidBrush(RGB(255,255,255)))
return; brush.UnrealizeObject();
pDrawDC->FillRect(client, &brush);

} if (!pDC->IsPrinting())
{
CFont    *oldFont;
//char     buf[12];
    oldFont = dc.SelectObject(m_font);
CFile     DeepFile("水深数据.txt",CFile::modeCreate|CFile::modeReadWrite);
CString   buf1;
char      buf2[]="x坐标     y坐标     水深数据     \r\n"; 
//buf1.Format("%s",buf2);
//wsprintf(buf1,"x坐标   y坐标   水深数据");
DeepFile.Write(buf2,strlen(buf2));
    
for(int i=0;i<1000;i+=100) for(int j=0;j<500;)
{   

buf1.Format("%5d      %5d      %5d      \r\n",i,j,i+j);
   //wsprintf(buf2,buf1);
//if(k>10)
// {buf1+='\n';
// k=0;
// }
DeepFile.Write(buf1,strlen(buf1));
j+=50;
//k++;
}
DeepFile.Close();
CStdioFile file_src;
CStringArray strArray;
file_src.Open("水深数据.txt",CFile::modeRead|CFile::typeText);
CString strTemp;
CString strTemp2;
CString strTemp3;
CString strTemp4;
int index=0;
while(file_src.ReadString(strTemp))
{
strArray.Add(strTemp);
index++;
/// TRACE("this is %d !\n",index);
}


for(i=1;i<index;i++)
{ strTemp=strArray[i];
//if(strTemp==NULL)
// break;
if(strTemp=="x坐标     y坐标     水深数据     \r\n")
continue;
strTemp2=strTemp.Left(10);
strTemp3=strTemp.Mid(11,10);
strTemp4=strTemp.Right(21);
dc.TextOut(atoi(strTemp2),atoi(strTemp3),strTemp4);

}
file_src.Close();
  
// if(!m_bBoatTrackFlag)
// {  m_bBoatTrackFlag=TRUE;
//    DrawBoatTrackDisplay(pDrawDC);
// }
CPen lPen;
lPen.CreatePen(PS_DASH,1,RGB(255,0,0));
dc.SelectObject(&lPen);
dc.MoveTo(0,0);
dc.LineTo(30000,30000);
dc.SelectObject(oldFont);

}

// pDoc->Draw(pDrawDC, this); //print or drawing if (pDrawDC != pDC)//drawing in the view
{
TRACE("this is in CBoatView Ondraw!\n");
pDC->SetViewportOrg(0, 0);
pDC->SetWindowOrg(0,0);
pDC->SetMapMode(MM_TEXT);
dc.SetViewportOrg(0, 0);
dc.SetWindowOrg(0,0);
dc.SetMapMode(MM_TEXT);
     pDC->BitBlt(rect.left-2, rect.top-2, rect.Width()+4, rect.Height()+4,
&dc, -2,-2, SRCCOPY); //Modifed on March 20,2001, to kill the bug of updating
dc.SelectObject(pOldBitmap);
}
}
希望各位能够帮帮忙?至于分数简直没有问题!!!