wxColour - Recording RGB Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
TransButtah
Earned a small fee
Earned a small fee
Posts: 16
Joined: Wed Oct 25, 2006 12:35 am

wxColour - Recording RGB

Post by TransButtah »

For my program, when the user changes the color using a color dialog, I would like the program to send the Red, Green, and Blue values to a file so they can be loaded next time the program starts up. I have been trying to use wxColour::Red(), wxColour::Blue(), and wxColour::Green(), like this:

Code: Select all

wxColour Color1(0,0,75);
wxTextFile file1;
file1.Open(wxT("Colors.txt"));
file1[0] = Color1.Red();
file1[1] = Color1.Green();
file1[2] = Color1.Blue();
file1.Close();
This doesn't seem to work, though. Anybody know what's wrong? I know how to make it load the colors on startup, but I just can't figure this part out.

Thanks!
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Post by doublemax »

you always have to call wxTextFile::Write() to submit the changes you've made:
http://www.wxwidgets.org/manuals/2.6.3/ ... tfileclose
Use the source, Luke!
TransButtah
Earned a small fee
Earned a small fee
Posts: 16
Joined: Wed Oct 25, 2006 12:35 am

Post by TransButtah »

Thanks! Stupid me. It works perfectly now, the colors can be reloaded and loaded whenever needed.

Thanks!
pschaich
Experienced Solver
Experienced Solver
Posts: 68
Joined: Wed Mar 09, 2005 4:19 pm
Location: Germany

Post by pschaich »

Just a little tip:

to make the conversion Colour <-> string easier, there are the functions

wxString GetAsString(long flags) const

and

bool Set(const wxString & str)

to get and set colours from one String

http://wiki.wxwidgets.org/docbrowse.cgi ... etasstring
Post Reply