Ever wanted to get COLORREF value from string? use this
COLORREF CClassName::GetColorFromStr(char * str)
{
int r = 255,g = 255,b = 255;
if(str && strlen(str)>=5) // minimum size
{
CString sStr(str);
int curPos= 0;
CString resToken= sStr.Tokenize(",",curPos);
int nIndex=0;
while (resToken != "")
{
if(nIndex == 0)
r = atoi(resToken);
else if (nIndex == 1)
g = atoi(resToken);
else
b= atoi(resToken);
nIndex++;
resToken= sStr.Tokenize(",",curPos);
};
}
return RGB(r,g,b);
}
1 תגובות:
thanks
Post a Comment