本文主要是介绍HTML颜色格式#FFFFFF转换为COLORREF方法,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
老土的方式:
szColor.Replace("#", "");int iArrColor[6] = {0};TCHAR hexSeed[] = _T("0123456789ABCDEF");for (int i = 0; i < 6; i++){TCHAR tcByte = szColor.GetAt(i);for (int j=0; j < 16; j++){if (tcByte == hexSeed[j]){iArrColor[i] = j;}}}COLORREF rgbColor = RGB(iArrColor[0] * 16 + iArrColor[1], iArrColor[2] * 16 + iArrColor[3], iArrColor[4] * 16 + iArrColor[5]);
新思路:
CString m_BackColor.m_frame_color = "#0290D8";DWORD r,g,b;
sscanf(m_BackColor.m_frame_color,"#%2X%2X%2X",&r,&g,&b);
COLORREF rgb = RGB(r,g,b);
brush.CreateSolidBrush (rgb)
这篇关于HTML颜色格式#FFFFFF转换为COLORREF方法的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!