drawtext在位图bitmap上无法输出文字
如有中英文错误,是上贴时输入的。
擦除了背景色
void CEc31View::OnDraw(CDC* pDC){ CDC dc; dc.CreateCompatibleDC(NULL); CRect rect; GetClientRect(&rect); CBitmap bitmap; bitmap.CreateCompatibleBitmap(pDC,rect.Width(),rect.Height()); dc.SelectObject(bitmap); dc.FillSolidRect(0,0,rect.Width(),rect.Height(),RGB(255,255,255)); dc.SelectObject(m_bitmap); m_measure.Draw(&dc);// m_measure.Draw(pDC); //不正确// dc.DrawText("dffdfdfd",CRect(0,0,100,100),DT_LEFT | DT_TOP); //可以正确输出 pDC->BitBlt(0,0,rect.Width(),rect.Height(),&dc,0,0,SRCCOPY); bitmap.DeleteObject(); dc.DeleteDC();}//方法m_measure.Draw(&dc); 内调用的DrawLine(CDC* pDC,MeasureInfo* temp)void CMeasure::DrawLine(CDC* pDC,MeasureInfo* temp){ //线 if(temp->nCount < 2) return ; pDC->MoveTo(temp->pDrawPt[0]); pDC->LineTo(temp->pDrawPt[1]); //可正确画线 int x,y,a,b; x=temp->pDrawPt[0].x+1; y=temp->pDrawPt[0].y+1; a=temp->pDrawPt[0].x+100; b=temp->pDrawPt[0].y+100; //x y a b四个值正确// int i=pDC->DrawText("dfsdf",CRect(x, //不能输出 dfsdf/// y,a,b),DT_LEFT | DT_TOP); int i=pDC->DrawText(temp->str,CRect(temp->pDrawPt[0].x+1, // i 的返回值不正常,有时很大 temp->pDrawPt[0].y+1,temp->pDrawPt[0].x+100,temp->pDrawPt[0].y+100),DT_LEFT | DT_TOP);}