Link to home
Start Free TrialLog in
Avatar of AsifMughal
AsifMughal

asked on

Problem with COLORREF type

Hello

I am trying to give the user the option to change the background colour of a List Box and store the selected colour in the ini file, so that it will re-appear when they logon on again.  The code I am using is as follows:

void CPatientView::OnTextCol()
{
            // TODO: Add your control notification handler code here
CPatientDoc* pDoc = GetDocument();
CColorDialog dlg;
//dlg.SetCurrentColor(pDoc->GetColor());
if (dlg.DoModal() == IDOK)
{
      COLORREF color = dlg.GetColor();
      
      //CString Temp;
      //Temp.Format("%s", (LPCTSTR)color);
      OUR_APP->WriteProfileString( "Colours", "Background", LPCTSTR(color));
      

}

The main problem is that the entry written in the ini file is always null, whichever colour the user selects.

As far as I am aware the COLORREF type is a RGB value, can I store this in anyway in the INI file.

I very much look forward to a reply

Thanks in advance.
      

}
ASKER CERTIFIED SOLUTION
Avatar of snoegler
snoegler

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Don't give me credit for this, but you're going about it the hard way!!!

How about just...

WriteProfileInt( "Colours", "Background", color );

and

color = GetProfileInt( "Colours", "Background", RGB( default ));

Phillip
Avatar of snoegler
snoegler

Sorry you are right. I don't have to do much with these WriteProfile... things, so i didn't see that
there is a function for writing an integer.
I think you should get the points :(
Well, I feel guilty for answering an answered question!

Phillilp