I have written a editor program but its not accepting more than 100 characters although I have declared the array size to be of 500. The scroll bar does not move beyond 100 characters in the 1st line of text.
const MAX_LINES = 500;
class CEditor5Doc : public CDocument
{
protected: // create from serialization only
CEditor5Doc();
DECLARE_DYNCREATE(CEditor5Doc)
CSize m_sizeDoc;
// Attributes
public:
CSize GetDocSize ( ) {return m_sizeDoc;}
// Operations
public:
//CSize GetDocSize ( ) { return m_sizeDoc;}
CString data_string[MAX_LINES];
CString out_string;
long line_number;
int yorigin;
// Overrides
:
:
};
CEditor5Doc::CEditor5Doc()
{
// TODO: add one-time construction code here
line_number = 0;
m_sizeDoc = CSize (800, 1000);
}
void CEditor5View::OnDraw(CDC* pDC)
{
CEditor5Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
TEXTMETRIC tm;
pDC->GetTextMetrics(&tm);
int yval=0;
for(int loop_index =0; loop_index <= pDoc->line_number; loop_index++){
pDC->TextOut(0, yval, pDoc->data_string[loop_index], pDoc->data_string[loop_index].GetLength());
yval+= tm.tmHeight;
}
// TODO: add draw code for native data here
}
void CEditor5View::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
CEditor5Doc* pDoc = GetDocument ( );
CClientDC dc(this);
OnPrepareDC(&dc);
//if(nChar == '\r') {
// pDoc->line_number++;
//}
//else {
pDoc->data_string[pDoc->line_number] += nChar;
TEXTMETRIC tm;
dc.GetTextMetrics(&tm);
dc.TextOut(0, (int) pDoc->line_number * tm.tmHeight, pDoc->data_string[pDoc->line_number], pDoc->data_string[pDoc->line_number].GetLength());
//}
pDoc->UpdateAllViews(this, 0L, NULL);
pDoc->SetModifiedFlag();
CView::OnChar(nChar, nRepCnt, nFlags);
}
void CEditor5View::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
SetScrollSizes(MM_TEXT, GetDocument()->GetDocSize());
// TODO: Add your specialized code here and/or call the base class
}
View class CSrollView.
Can somebody please help me
Zulfi.
const MAX_LINES = 500;
class CEditor5Doc : public CDocument
{
protected: // create from serialization only
CEditor5Doc();
DECLARE_DYNCREATE(CEditor5Doc)
CSize m_sizeDoc;
// Attributes
public:
CSize GetDocSize ( ) {return m_sizeDoc;}
// Operations
public:
//CSize GetDocSize ( ) { return m_sizeDoc;}
CString data_string[MAX_LINES];
CString out_string;
long line_number;
int yorigin;
// Overrides
:
:
};
CEditor5Doc::CEditor5Doc()
{
// TODO: add one-time construction code here
line_number = 0;
m_sizeDoc = CSize (800, 1000);
}
void CEditor5View::OnDraw(CDC* pDC)
{
CEditor5Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
TEXTMETRIC tm;
pDC->GetTextMetrics(&tm);
int yval=0;
for(int loop_index =0; loop_index <= pDoc->line_number; loop_index++){
pDC->TextOut(0, yval, pDoc->data_string[loop_index], pDoc->data_string[loop_index].GetLength());
yval+= tm.tmHeight;
}
// TODO: add draw code for native data here
}
void CEditor5View::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
CEditor5Doc* pDoc = GetDocument ( );
CClientDC dc(this);
OnPrepareDC(&dc);
//if(nChar == '\r') {
// pDoc->line_number++;
//}
//else {
pDoc->data_string[pDoc->line_number] += nChar;
TEXTMETRIC tm;
dc.GetTextMetrics(&tm);
dc.TextOut(0, (int) pDoc->line_number * tm.tmHeight, pDoc->data_string[pDoc->line_number], pDoc->data_string[pDoc->line_number].GetLength());
//}
pDoc->UpdateAllViews(this, 0L, NULL);
pDoc->SetModifiedFlag();
CView::OnChar(nChar, nRepCnt, nFlags);
}
void CEditor5View::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
SetScrollSizes(MM_TEXT, GetDocument()->GetDocSize());
// TODO: Add your specialized code here and/or call the base class
}
View class CSrollView.
Can somebody please help me
Zulfi.