Hello,
im currently making a save function for my Project wich is like this :

private: System::Void Form1_FormClosing(System::Object^  sender, System::Windows::Forms::FormClosingEventArgs^  e) 
		 {
			 	String^Sleeptime = textBox4->Text;
	                        StreamWriter^ sWriter = gcnew StreamWriter("c:\\DoNotEdit !.txt");
				sWriter->WriteLine(Sleeptime);				

				sWriter->Flush();
			        sWriter->Close();
		 }

And this for the load function:

private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) 
        {	 	      

		        if ( File::Exists("c:\\DoNotEdit !.txt") )
	{
			StreamReader^ myFile = File::OpenText("c:\\DoNotEdit !.txt");  
                        Form1::textBox4->Text = myFile->ReadLine();

			myFile->Close();
	}
           else
        {
            	StreamWriter^ sWriter = gcnew StreamWriter("c:\\DoNotEdit !.txt");
		sWriter->WriteLine(100);
		sWriter->Close();
         }

But now im trying to save and load the color picked of a ColorDialog.
(The user can choose a Color and the background of the form becomes the picked color)
(http://msdn.microsoft.com/en-us/library/system.windows.forms.colordialog.aspx)

I tryed some stuff, but it all didn't worked.
So what should is use to get it working ?
Help is greatly appreciated !

Recommended Answers

All 3 Replies

Thanks for you replay :)
But im quite new to this.
I wonder how i could make a function wich writes the color as plain text.

this->comboBox1->ForeColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(255)), static_cast<System::Int32>(static_cast<System::Byte>(192)),static_cast<System::Int32>(static_cast<System::Byte>(192)));

For example that color ?

Oh, well, that's even easier. Just write out the RGB values as text and read them back in again.

int firstnum = 255;
//etc.
sw->WriteLine(firstNum.ToString()+" "+secondNum.ToString()+" "+thirdNum.ToString());

Read the line back in and parse the numbers out from the string to get them back.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.