如何将COLORREF变量值如RGB(0,0,0)转换为CString类型的值?
反向又如何转化
反向又如何转化
解决方案 »
- DHTML Edit Control for IE5打不开带编码的文件内部url,如何改动或设置可以令其打开?
- word(office)字体显示和打印高度不致的问题
- 我关于全局指针的一点设想
- VCM 问题! ICGetState函数返回的信息是一个什么样的结构呢!,那里有说明文档
- 100分求助!!!socket被阻塞,是否接受缓冲不够大?
- 请问C/S架构的概念,跟B/S架构的关键区别(请具体说明)
- ............如何从拨号客户端得到拨号服务器的IP地址(Win98)?
- 用RasSetEntryProperties建立拨号连接的问题?高分相送
- VC中,MFC编程如何插入位图图像
- argument 是什么意思?
- 请问如何打开一个文件夹并获得其中文件的相关信息
- 我连上一个无线网络,被自动分配了ip,但是没得到网关ip,用xxx.xxx.xxx.1也不行,怎么办?
void LIni::WriteColRef(CString strEntry, COLORREF cr, LPCSTR strSection)
{
CString strBuffer;
strBuffer.Format("RGB(%d,%d,%d)",GetRValue(cr), GetGValue(cr), GetBValue(cr));
WritePrivateProfileString(m_strSection, strEntry, strBuffer, m_strIniFile);
}
// 读取
COLORREF LIni::GetColRef(CString strEntry, COLORREF crDefault, LPCSTR strSection)
{
int temp[3]={GetRValue(crDefault),GetGValue(crDefault),GetBValue(crDefault)}; CString strDefault;
strDefault.Format("RGB(%hd,%hd,%hd)",temp[0],temp[1],temp[2]); // 注:GetString 用于从 INI 文件中读出文本数据
CString strColRef = GetString(strEntry,strDefault,strSection);
sscanf(strColRef,"RGB(%d,%d,%d)", temp, temp+1, temp+2); return RGB(temp[0],temp[1],temp[2]);
}
strR.Format("%d|",m_R);//m_R,m_G,m_B分别是颜色的分量值
strG.Format("%d|",m_G);
strB.Format("%d|",m_B);
str = strR + strG + strB ;//把这个字符串写到ini文件
所以得到字符串的形式为:m_R|m_G|m_B...
当要写入时分析字符串就是了,再用函数atoi()把字符串转换成数字就可以了。