I am finishing up my text editor that saves the font and size and then displays the text according to the saved info. So far I have the program writing the font name and size then $$ to mark the end of my font info and the beginning of the saved text.
First problem. Everytime I save the file it writes the font and size again. Suggestions?
Second problem. When I display the file I want only the text to show. More suggestions?
Code:private: System::Void OpenBtn_Click(System::Object * sender, System::EventArgs * e) { OpenFileDialog * fd = new OpenFileDialog(); if(fd->ShowDialog() == DialogResult::OK) { FileStream * fs = new FileStream(fd->FileName, FileMode::Open); StreamReader * sr = new StreamReader(fs); String * s = sr->ReadLine(); textBox1->Text = s; sr->Close(); } } private: System::Void SaveBtn_Click(System::Object * sender, System::EventArgs * e) { SaveFileDialog * fd = new SaveFileDialog(); if(fd->ShowDialog() == DialogResult::OK) { FileStream * fs = new FileStream(fd->FileName, FileMode::OpenOrCreate); StreamWriter * sw = new StreamWriter(fs); sw->Write(textBox1->Font->Name); sw->Write(textBox1->Font->Size); sw->Write("$$"); sw->WriteLine(textBox1->Text); sw->Flush(); sw->Close(); } } private: System::Void FontBtn_Click(System::Object * sender, System::EventArgs * e) { FontDialog* fd = new FontDialog(); fd->Font = FontLine; if(fd->ShowDialog() == DialogResult::OK) { FontLine = fd->Font; textBox1->Font = FontLine; } } }; }



LinkBack URL
About LinkBacks


