??COLORREF??????,?????sprintf???????????????:
COLORREF color = RGB(255, 0, 0); // ?? char strColor[9]; sprintf(strColor, "#XXX", GetRValue(color), GetGValue(color), GetBValue(color)); std::string strColorString = strColor; std::cout << strColorString << std::endl; // ????? "#FF0000"
????????COLORREF,?????sscanf???????????????:
std::string strColorString = "#FF0000"; int red, green, blue; sscanf(strColorString.c_str(), "#XXX", &red, &green, &blue); COLORREF color = RGB(red, green, blue); std::cout << std::hex << color << std::endl; // ??16?????COLORREF? 0x000000FF
???,?????????????Windows API?COLORREF??,????GetRValue?GetGValue?GetBValue???????????????????,????????