CString转COLORREF

来源:互联网 发布:淘宝联盟怎么分享图文 编辑:程序博客网 时间:2024/06/05 12:00

CString strColorText=RGB(255,0,0);
COLORREF color;
GetColorRGB(strColorText , color);

BOOL CStaticLink::GetColorRGB(CString& strColorText , COLORREF& color)

{   
strColorText=strColorText.Left(strColorText.GetLength()-1);
strColorText=strColorText.Right(strColorText.GetLength()-4);
CString chR= _T(""), chG= _T(""), chB= _T(""); 
AfxExtractSubString( chR, (LPCTSTR)strColorText, 0, ',');
AfxExtractSubString( chG, (LPCTSTR)strColorText, 1, ',');
AfxExtractSubString( chB, (LPCTSTR)strColorText, 2, ',');


color = RGB( _ttoi(chR),  _ttoi(chG),  _ttoi(chB));
return TRUE;
}
原创粉丝点击