了解以 Office 2007 样式使用 MFC 功能包时使用的颜色
我正在更新一些旧的 C++ 代码,以使用 Microsoft 为 Visual Studio 2008 发布的“MFC 功能包”。我们使用新类从 CFrameWndEx 派生我们的应用程序,并应用 Office 2007 样式来提供我们的应用程序。应用更现代的外观。 这为我们提供了渐变填充的窗口标题、状态栏等,以及功能区工具栏的使用。
但是,我们的应用程序包含一些所有者绘制的控件,我想更新这些控件以匹配功能包使用的配色方案。 理想情况下,我想知道当前使用的浅色和阴影工具栏颜色。
我已经搜索了文档和网络,但还没有找到任何东西。 有谁知道如何找到这些信息吗?
[编辑]
我们特别需要找出运行时使用的颜色。 您可以使用新的静态函数 CMFCVisualManager::SetDefaultManager 在运行时更改应用程序的外观。
下面的 msdn 页面向您展示了可用的样式类型,特别是 Office2007 的外观: msdn 链接
I'm updating some of our legacy C++ code to use the "MFC feature pack" that Microsoft released for Visual Studio 2008. We've used the new classes to derive our application from CFrameWndEx, and are applying the Office 2007 styles to give our application a more modern appearance. This gives us gradient filled window titles, status bars etc, and the use of the ribbon toolbars.
However, our application contains some owner drawn controls, and I'd like to update these to match the color scheme used by the feature pack. Ideally I'd like to know the light and shaded toolbar colors that are currently in use.
I've had a hunt around the documentation and web and have not yet found anything. Does anyone know how to find this information out?
[Edit]
In particular we need to find out which colors are being used at runtime. You can change the appearance of your application at runtime using the new static function CMFCVisualManager::SetDefaultManager.
The following msdn page shows you what kind of styles are available, in particular the Office2007 look:
link to msdn
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
您是否查看过 MFC 源代码,您可以在
C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\src\mfc之类的位置找到它
Have you looked in the MFC source code, which you'll find in something like
C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\src\mfc
很好的建议,但不幸的是,当我当前使用 CMFCVisualManagerOffice2007::Office2007_LunaBlue 样式运行我的应用程序时,它们只是返回各种灰色阴影
令人烦恼的是,msdn 帮助“正在建设中”,所以甚至不告诉你它们应该是什么正在做!
Good suggestion, but unfortunately they just return various shades of grey, when currently I'm running my application with the style CMFCVisualManagerOffice2007::Office2007_LunaBlue
Annoyingly the msdn help is "under construction" so doesn't even tell you what they are supposed to be doing!
afxGlobalData
包含有关 MFC 功能包当前使用的颜色、画笔和字体的一些有用信息。 特别是,我在绘制自己的控制栏背景时使用afxGlobalData.m_clrBarFace
。(请注意,我不在我的工作电脑前,所以上面的语法不正确。)
afxGlobalData
contains some useful information on the current colours, brushes and fonts being used by the MFC Feature Pack. In particular I useafxGlobalData.m_clrBarFace
when painting my own control bar backgrounds.(note that I am not in front of my work PC so the above syntax isn't spot on.)
您是否尝试过:2007 Office系统文档:解决方案和加载项的 UI 样式指南
?
Have you tried: 2007 Office System Document: UI Style Guide for Solutions and Add Ins
?
我想您可以使用您最喜欢的图像编辑器并从屏幕抓取中选择颜色。
I guess you could use your favourite image editor and pick the colors from a screen grab.
“我想你可以使用你最喜欢的图像编辑器并从屏幕抓取中选择颜色。”
这基本上就是我现在正在做的事情,我定义了一个常量列表,从中提取颜色。 虽然看起来不太优雅!
"I guess you could use your favourite image editor and pick the colors from a screen grab."
This is essentially what I'm doing at the moment, and I've defined a list of constants from which I pull out the colours. Doesn't seem very elegant though!
看起来 CMFCVisualManager 提供了几种获取颜色信息的方法,例如
查看 CMFCVisualManager 的 MSDN 文档。
Looks like CMFCVisualManager offers several methods for getting color information, e.g.
Take a look at the MSDN docs for CMFCVisualManager.
@GateKiller,OP 并未开发 Office 2007 加载项,因此 UI 指南不会真正有帮助。 这是一个使用 Visual C++ 2008 功能包,它允许 MFC 应用程序呈现 Office 2007 的外观和感觉。
@GateKiller, the OP isn't developing an Office 2007 add-in, so the UI guidelines won't really help. It's an MFC application using the Visual C++ 2008 Feature Pack which allows MFC apps to take on the Office 2007 look and feel.
- clrFace 输出参数是灰色的?
也许它们都是每个主题的单一基本色调之上的面具? 假设您可以使用 CMFCVisualManagerOffice2007::GetStyle() 确定哪种配色方案有效,也许您可以找出该色调是什么,然后使用 GetxxxColor() 方法进行一些屏蔽。
CMFCVisualManagerOffice2007::GetTabFrameColors - the clrFace output param is grey?
Perhaps they're all masks on top of a single base hue for each theme? Assuming you can determine which color scheme is in effect with CMFCVisualManagerOffice2007::GetStyle(), perhaps you can figure out what that hue is and then do some masking with the GetxxxColor() methods.