主题:[讨论]undeclared identifier!!!
void CEx_TextView::OnDraw(CDC* pDC)
{
CEx_TextDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
CFont cf;
cf.CreateFontIndirect(&m_lfText);
CFont*oldFont=pDC->SelectObject(&cf);
TEXTMETRIC tm;
pDC->GetTextMetrics(&tm);
int lineHeight=tm.tmHeight+tm.tmExternalLeading;
int y=0;
int tab=tm.tmAveCharWidth*4;
int lineMaxWidth=0;
CString str;
CSize lineSize(0,0);
for(int i=0;i<pDoc->m_strContents.GetSize();i++){
str=pDoc->m_strContents.GetAt(i);
pDC->TabbedTextOut(0,y,str,1,&tab,0);
str=str+"A";
lineSize=pDC->GetTabbedTextExtent(str,1,&tab);
if(lineMaxWidth<lineSize.cx)
lineMaxWidth=lineSize.cx;
y+=lineHeight;
}
pDC->SelectObject(oldFont);
int nLine= pDoc->m_strContents.GetSize()+1;
CSize sizeTotal;
sizeTotal.cx=lineMaxWidth;
sizeTotal.cy=lineHeight*nLines;
SetScrollSizes(MM_TEXT,sizeTotal);
}
这是一个程序段,在调试后出现错误提示:error C2065: 'nLines' : undeclared identifier
应该怎么解决.谢谢~~~
{
CEx_TextDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
CFont cf;
cf.CreateFontIndirect(&m_lfText);
CFont*oldFont=pDC->SelectObject(&cf);
TEXTMETRIC tm;
pDC->GetTextMetrics(&tm);
int lineHeight=tm.tmHeight+tm.tmExternalLeading;
int y=0;
int tab=tm.tmAveCharWidth*4;
int lineMaxWidth=0;
CString str;
CSize lineSize(0,0);
for(int i=0;i<pDoc->m_strContents.GetSize();i++){
str=pDoc->m_strContents.GetAt(i);
pDC->TabbedTextOut(0,y,str,1,&tab,0);
str=str+"A";
lineSize=pDC->GetTabbedTextExtent(str,1,&tab);
if(lineMaxWidth<lineSize.cx)
lineMaxWidth=lineSize.cx;
y+=lineHeight;
}
pDC->SelectObject(oldFont);
int nLine= pDoc->m_strContents.GetSize()+1;
CSize sizeTotal;
sizeTotal.cx=lineMaxWidth;
sizeTotal.cy=lineHeight*nLines;
SetScrollSizes(MM_TEXT,sizeTotal);
}
这是一个程序段,在调试后出现错误提示:error C2065: 'nLines' : undeclared identifier
应该怎么解决.谢谢~~~