
CEdit multiline Get line by line ?!?
Hi
I try to read the text of a multiline CEdit Control line by line and
write this to a specified file. So far so good but the length of the
lines makes me trouble.
When I read the first line with 10 characters and the second with only 5
characters the text displayed in my file has for each line only 5
characters.
I use a "for" loop for reading and writing. This loop takes the last
line length as the line length for each line. Is there a possibility to
do this in another way or can anybody give me a hint for correcting this
loop ?
Here is my code:
#define MAX_FILE_SIZE 10000
void CHTML_KonvertierungDlg::OnButton1()
{
if(m_FileName.LineLength==0){
AfxMessageBox("Please type a correct file and pathname");
return;
}
CString strTemp;
m_FileName.GetWindowText(strTemp);
CFile tempFile(strTemp,CFile::modeCreate|CFile::modeWrite);
char a[MAX_FILE_SIZE];
int b=m_Text.GetLineCount();
int t =m_Text.LineIndex();
for ( t=0;t<b;t++)
{
int nLen = m_Text.LineLength();
m_Text.GetLine(t,a,nLen);
a[nLen] ='\0';
int n_Size = sizeof(nLen);
tempFile.Write(a,nLen);
}
tempFile.Close();
Quote:
}