Vista风格的CMFCButton [英] CMFCButton with Vista Style

查看:120
本文介绍了Vista风格的CMFCButton的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎无法在对话框应用程序中以Vista样式显示CMFCButton.我正在将VS2008与MFC Feature Pack一起使用.

I can't seem to get a CMFCButton to be displayed in Vista style in a dialog box application. I'm using VS2008 with MFC Feature Pack.

以下是重现我的问题的一些步骤:

Here are some steps to reproduce my problem:

  • 创建一个新的MFC项目;
  • 指定基于对话框的项目.
  • 在主对话框中添加两个按钮.
  • 为每个按钮添加一个变量.将其中一个变量设为CButton,将另一个变量设为CMFCButton.
  • 编译并运行.

测试应用图片http://img7.imageshack.us/img7/3/testapp.png

如您所见,CButton具有正确的样式,但CMFCButton没有.

As you can see, the CButton has the correct style but the CMFCButton does not.

我在这里想念什么?

推荐答案

默认情况下, CMFCButton 具有 BS_OWNERDRAW 样式-您可以在中将其删除您的对话框的OnInitDialog():

The CMFCButton has the BS_OWNERDRAW style set by default - you can remove it in the OnInitDialog() for your dialog:

mfcButton.ModifyStyle(BS_OWNERDRAW, 0, 0);

但是,删除所有者绘制样式会导致CMFCButton的许多方法都变得无用(例如SetTextColor).您可以通过设置视觉管理器来获取使用当前Windows主题渲染的按钮:

However, removing the owner draw style results in many of the methods of CMFCButton being rendered useless (e.g. SetTextColor). You can get the button to render using the current windows theme by setting up the visual manager:

CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows));

完成此操作,而不是上面的 ModifyStyle ,导致按钮符合默认样式,但仍具有较新的呈现功能.

This is done instead of the ModifyStyle above, resulting in buttons that fit the default style but still have the newer rendering features.

这篇关于Vista风格的CMFCButton的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆