HTML颜色名目#FFFFFF转换为COLORREF要领
当前位置:以往代写 > C/C++ 教程 >HTML颜色名目#FFFFFF转换为COLORREF要领
2019-06-13

HTML颜色名目#FFFFFF转换为COLORREF要领

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)

作者:csdn博客 微wx笑

    关键字:

在线提交作业