VS2008下改变radio控件字体颜色存在的问题
2012-01-24 18:02
369 查看
通过OnCtlColor函数试图改变radio控件字体的颜色为白色,代码如下:
运行程序,发现无法改变Radio控件的颜色,程序运行截图如下:
经过试验,发现当程序使用的DLLs是通过Manifest指定,Radio Button就不能改变其字体颜色,不过界面有XP风格,如上图所示。
经过试验发现可以使用如下方法改变Radio Button的文本颜色:
使用"open"按钮来打开编译后生成的exe文件,打开后如下图所示:
打开RT_MANIFEST展开项“1”的内容,内容如下:
上面的XML格式的文件是Visual Studio 2008自动生成的,从最后部分的蓝色标记可以看出,加载的comctl32.dll 是从C:\WINDOWS\WinSxS\ 文件夹下加载的。当把这部分删除,再运行程序发现radio button的颜色变成白色了。
注:comctl32.dll 在WinSxS文件夹下x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.6028_x-ww_61e65202文件夹下。
删除操作截图:
执行后效果:
但是这种方法有一个问题,虽然radio控件的字体颜色改变了,但其界面的xp风格却没有了。
不知道大家有没有好的方法改变Radio Button的文本颜色, 而且最好还有保留XP风格,代码越简洁越好啊。
参考:http://topic.csdn.net/u/20071008/19/DE3A4292-558E-4D91-BED9-D9DC27BDBBAF.html
~~~~~~~~~~~~~~~~~~~~~
RT_MANIFEST是什么文件?
DentistryDoctor:通过Mainfest可以指定CommonControl的版本
Since Windows XP, Windows reserves a new type of resource RT_MANIFEST for SxS manifests.
Within the RT_MANIFEST resource, Windows reserves ID 1-16. A binary cannot have two IDs of resource type RT_MANIFEST within 1-16. Windows will refuse to load such binary in Windows XP/Windows Server 2003.
Only three IDs are used today in Windows.
HBRUSH CXXXDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); if( pWnd ->GetDlgCtrlID() == IDC_RADIO1_ONE) { pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(RGB(255,255,255)); //白色字体 return HBRUSH(GetStockObject(HOLLOW_BRUSH)); } return hbr; }
运行程序,发现无法改变Radio控件的颜色,程序运行截图如下:
经过试验,发现当程序使用的DLLs是通过Manifest指定,Radio Button就不能改变其字体颜色,不过界面有XP风格,如上图所示。
经过试验发现可以使用如下方法改变Radio Button的文本颜色:
使用"open"按钮来打开编译后生成的exe文件,打开后如下图所示:
打开RT_MANIFEST展开项“1”的内容,内容如下:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> <security> <requestedPrivileges> <requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel> </requestedPrivileges> </security> </trustInfo> <dependency> <dependentAssembly> <assemblyIdentity type="win32" name="Microsoft.VC90.DebugCRT" version="9.0.21022.8" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity> </dependentAssembly> </dependency> <dependency> <dependentAssembly> <assemblyIdentity type="win32" name="Microsoft.VC90.DebugMFC" version="9.0.21022.8" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity> </dependentAssembly> </dependency> <dependency> <dependentAssembly> <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="x86" publicKeyToken="6595b64144ccf1df" language="*"></assemblyIdentity> </dependentAssembly> </dependency> </assembly>
上面的XML格式的文件是Visual Studio 2008自动生成的,从最后部分的蓝色标记可以看出,加载的comctl32.dll 是从C:\WINDOWS\WinSxS\ 文件夹下加载的。当把这部分删除,再运行程序发现radio button的颜色变成白色了。
注:comctl32.dll 在WinSxS文件夹下x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.6028_x-ww_61e65202文件夹下。
删除操作截图:
执行后效果:
但是这种方法有一个问题,虽然radio控件的字体颜色改变了,但其界面的xp风格却没有了。
不知道大家有没有好的方法改变Radio Button的文本颜色, 而且最好还有保留XP风格,代码越简洁越好啊。
参考:http://topic.csdn.net/u/20071008/19/DE3A4292-558E-4D91-BED9-D9DC27BDBBAF.html
~~~~~~~~~~~~~~~~~~~~~
RT_MANIFEST是什么文件?
DentistryDoctor:通过Mainfest可以指定CommonControl的版本
Since Windows XP, Windows reserves a new type of resource RT_MANIFEST for SxS manifests.
Within the RT_MANIFEST resource, Windows reserves ID 1-16. A binary cannot have two IDs of resource type RT_MANIFEST within 1-16. Windows will refuse to load such binary in Windows XP/Windows Server 2003.
Only three IDs are used today in Windows.
相关文章推荐
- 从CStatic派生新类,形成具有可以改变字体、背景颜色 和字体颜色的控件类
- 浅谈vc里控件的字体和颜色的改变
- 图形的绘制,如何使用自定义画笔(颜色,线宽,线形)。如何为程序中添加选项菜单和选项设置对话框,如何使用标准颜色对话框,如何使用字体对话框,在选项对话框中实现预览功能。实现选项对话框和窗口类中的数据交换。如何改变对话框和控件的背景色,如何改变控件的文本颜色,
- tableview 自定义cell 点击cell改变cell中的label.text的字体颜色,cell复用出现问题
- 关于Radiobutton 改变字体颜色问题
- VC改变控件的背景颜色 字体 文本颜色
- 改变 MFC 对话框 static 控件的字体颜色
- sdk编程改变static控件字体和颜色
- vs2008 动态设置Edit Control控件的背景及字体颜色
- radio和label关联问题,点击label改变颜色
- 改变控件的背景颜色和字体颜色
- 怎么改变Extjs控件的样式(字体颜色、背景颜色等)
- VC改变控件的背景颜色 字体 文本颜色
- RadioGroup 的 RadioButton 选择改变字体颜色和背景颜色(通过XML设置)
- 改变MFC对话框背景色、控件内的字体颜色和背景色
- RadioGroup 的 RadioButton 选择改变字体颜色和背景颜色
- 改变List列表控件中的字体颜色和单元格背景颜色
- 关于VS2008下MFC中控件字体的改变
- VC++ 控件改变编辑框字体和颜色
- C#中代码Dialog控件实现(打开,保存,改变字体,颜色,打印功能)