I'm making a Notepad clone. Right now my text loads fine but where their are newline characters, they do not make newlines in the text field.
I load it like this:
void LoadText(HWND ctrl,HWND parent)
{
int leng;
char buf[330000];
char FileBuffer[500];
memset(FileBuffer,0,500);
FileBuffer[0] = '*';
FileBuffer[1] = '.';
FileBuffer[2] = 't';
FileBuffer[3] = 'x';
FileBuffer[4] = 't';
OPENFILENAMEA ofn;
memset(&ofn, 0, sizeof(OPENFILENAMEA));
ofn.lStructSize = sizeof(OPENFILENAMEA);
ofn.hwndOwner = parent;
ofn.lpstrFile = FileBuffer;
ofn.nMaxFile = 500;
ofn.lpstrFilter = "Filetype (*.txt)\0\0";
ofn.lpstrDefExt = "txt";
ofn.Flags = OFN_EXPLORER;
if(!GetOpenFileNameA(&ofn))
{
return;
}
ifstream *file;
file = new ifstream(FileBuffer,ios::in);
int lenn;
lenn = 0;
while (!file->eof())
{
buf[lenn] = file->get();
lenn += 1;
}
buf[lenn - 1] = 0;
file->read(buf,lenn);
SetWindowTextA(ctrl,buf);
file->close();
}
How can I make it do the new line characters?
Thanks
(Fixed it, turns out the stream was not giving me CR's so I had to insert them.