Chris MacDougall
October 6th, 1999, 03:48 PM
I have an SDI "hyperterm" like app. I read data in a com port and save it to a CString and CStringList object in the DOC. I display the data in the OnDraw() call in VIEW. The OnDraw() has a loop and the code is shown below to better describe what the heck it is (becuase I think I have narrowed it down to a display problem in OnDraw()). Here it is:
if(pDoc->GetDataTest())
{
CStringList* pLineList = pDoc->GetLineList();//get ptr to list of strings in doc
m_tempData = pDoc->GetString(); //get current/1st string from DOC
CSize cplength = pDC->GetTextExtent(m_tempData); //calculate size of text box
m_clHeight = cplength.cy; //get y offset
int iLine;
int cLastLine;
int cyLine = 0;
iLine = m_iTopLine;
cLastLine = m_iTopLine + m_clHeight + 1;
cLastLine = min(cLastLine, pLineList->GetCount());
CString strLine;
POSITION pos;
while(iLine < cLastLine) //loop for line feed, and display
{
//Draw a line of text
if((pos = pLineList->FindIndex(iLine)) != NULL)
{
strLine = pLineList->GetAt(pos);
pDC->TextOut(0,cyLine,strLine);
cyLine += m_clHeight;
iLine++;
}
}
m_tempData.Empty(); //clear temp string
strLine.Empty(); //clear drawn string
}
//////////////END loop OnDraw()/////////////
Problem: Works great until it tries to display more than 17 strLine's.
Do you see anything that would cause my view to stop displaying after 17 strLine calls are displayed?
Also it is a CSrollView class and by the way my scrolls don't view. Why? or another problem for later. Please feel free to critique the rest of the code while your at it and if you feel so inclined. Any suggestions are welcomed - thanks.
if(pDoc->GetDataTest())
{
CStringList* pLineList = pDoc->GetLineList();//get ptr to list of strings in doc
m_tempData = pDoc->GetString(); //get current/1st string from DOC
CSize cplength = pDC->GetTextExtent(m_tempData); //calculate size of text box
m_clHeight = cplength.cy; //get y offset
int iLine;
int cLastLine;
int cyLine = 0;
iLine = m_iTopLine;
cLastLine = m_iTopLine + m_clHeight + 1;
cLastLine = min(cLastLine, pLineList->GetCount());
CString strLine;
POSITION pos;
while(iLine < cLastLine) //loop for line feed, and display
{
//Draw a line of text
if((pos = pLineList->FindIndex(iLine)) != NULL)
{
strLine = pLineList->GetAt(pos);
pDC->TextOut(0,cyLine,strLine);
cyLine += m_clHeight;
iLine++;
}
}
m_tempData.Empty(); //clear temp string
strLine.Empty(); //clear drawn string
}
//////////////END loop OnDraw()/////////////
Problem: Works great until it tries to display more than 17 strLine's.
Do you see anything that would cause my view to stop displaying after 17 strLine calls are displayed?
Also it is a CSrollView class and by the way my scrolls don't view. Why? or another problem for later. Please feel free to critique the rest of the code while your at it and if you feel so inclined. Any suggestions are welcomed - thanks.