RGB的CString格式转换为COLORREF
现有RGB:static COLORREF clrAuto = RGB(255, 255, 255);
<1>COLORREF格式的RGB转换为CString格式:_T("%d, %d, %d")
static CString FormatColor(COLORREF color)
{
CString str;
str.Format(_T("%d, %d, %d"), GetRValue(color), GetGValue(color), GetBValue(color));
return str;
}
<2>将RGB的CString格式转换为COLORREF
static COLORREF GetColorRGB(const CString& strColorText)
{
COLORREF color;
char chR[6] = "", chG[6] = "", chB[6] = "";
std::string str = CStringA(strColorText);
const char* chColor = str.c_str();
scanf(chColor, "%[^,],%[^,],%[^,]", chR, chG, chB);
color = RGB(atoi(chR), atoi(chG), atoi(chB));
return color;
}



