1 Replies - 483 Views - Last Post: 23 March 2018 - 01:31 PM

#1 hexagod   User is offline

  • 😂😂😂
  • member icon

Reputation: 31
  • View blog
  • Posts: 577
  • Joined: 29-October 16

Reading from .cfg File Possible on Multiple WinForms?

Posted 23 March 2018 - 01:18 PM

Hey all,
I am soon going to be switching to using C#/ASP.NET for my apps related to my day job, but I have been tasked with making the interface for my program more normie friendly. Right now, it's made for high contrast theme in windows and it's got a black background with changing color lettering. My company wants me to make it available for everyone and part of that includes making the interface more like one would get from a standard office product.

I spent a lot of time making the interface though so I am going to make the interface changeable by the user in a settings menu. Before you flame me for my n00bishness, just know that I am going to soon be scraping this project in favor of more modern C#/WPF/ASP.NET (as I said earlier)... This was basically the first program that I wrote in Visual C++ which actually was of massive use to me. I made a few mini projects that were just experiments but this one saves me a ton of time @ my job. I know my code is choppy and I've got a lot to learn but I just want to make this thing usable for more people and need a simple way to read a .cfg file.

The way that I'm doing it now is via:

colorSchemeSettings = System::IO::File::ReadAllText("colorScheme.cfg");


and then I use

		//colorScheme String^ is set to classic
		if (colorSchemeSettings = "classic")
		{
			//display the colorScheme setting in textBox3
			button2->Text = "classic";
			//give a readout of the state
			textBox3->Text = "This color scheme will only look right if you use the dark 'High Contrast' theme in windows";
		}
		//colorScheme String^ set to boring
		if (colorSchemeSettings == "zzzzzz")
		{
			//colorscheme is set to zzzzzz
			button2->Text = "zzzzzz";
			//tell the user to close the form and reload to get the new scheme to take affect
			textBox3->Text = "Color scheme set to white on black \n you must close windows before \n the changes will take effect";
		}


to set the colors

the problem is: when my first form loads, that logic is interpreted correctly by my program; but then when I load the settings form, the String^ loaded is not correct. I am using the

Form_Load (System::Object^  sender, System::EventArgs^  e) 


to read the config file then change the colors according to the user setting.

How can I read from the same .cfg file for all forms that load? Does anyone have any ideas why only one of the forms loads the String^ from the .cfg file correctly?

The only thing I can think of is that maybe I need to close the file on the first form load before I load on another?

Help me out lol

Is This A Good Question/Topic? 0
  • +

Replies To: Reading from .cfg File Possible on Multiple WinForms?

#2 hexagod   User is offline

  • 😂😂😂
  • member icon

Reputation: 31
  • View blog
  • Posts: 577
  • Joined: 29-October 16

Re: Reading from .cfg File Possible on Multiple WinForms?

Posted 23 March 2018 - 01:31 PM

wow I feel really dumb I forgot one of the '=' signs ...

delete this topic lol...

to answer my question yes you can read from one .cfg for all forms.

delete this hhahahaha
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1