MFC MDI和SDI非客户区框架界面美化之----界面全面美化
2014-02-12 10:49
801 查看
VS2008以上的开发平台,微软提供了“视觉管理器和样式”这么一个概念,目前包含了XP、WIN7、OFFICE等不同的风格,如下所示:
就以CMFCVisualManagerOffice2007 风格为例,这个类提供了很强大的界面框架美化结构,包含到每一个按钮,每一个容器,甚至是每一个图标。但是很不幸,里面的样式内容微软进行了封装,不允许用户进行改变。但是与其我们一张一张贴图,重绘,废了半天劲,可能还达不到预期的效果,为什么不能模仿微软自带的样式进行继承一个新的界面库呢?
CMFCVisualManagerOffice2007 类的界面背景主要由OnFillBarBackground函数进行填充绘制,其他工具栏、菜单栏、状态栏等等的重绘都对应着一个类似的函数。颜色管理主要由OnUpdateSystemColors函数进行管理。进行编写界面库前,必须深入的了解CMFCVisualManagerOffice2007 类的工作原理,继承过程,消息机制等要点。其他其他VS自带样式类似,不管是CMFCVisualManagerOffice2007或者CMFCVisualManagerOffice2003或者XP都是继承一个基类来完成。如果了解了这些,编写一个对应的界面库就不成问题了吧!
1、DEMO具体操作:
1、新建类,基类为CMFCVisualManagerOffice2007。</p>
2、声明要继承的虚函数,如virtual void OnUpdateSystemColors();</p>
3、重写对应函数,如:实现标题栏TITLE居左或者居中,(PS:再也不用重绘标题栏了吧!)</p>
void TestStyle::OnUpdateSystemColors()
{
CMFCVisualManagerOffice2007::OnUpdateSystemColors();
CMFCVisualManagerOffice2007::m_bNcTextCenter = FALSE;//标题栏Title 居左。TRUE:居中
}
4、视觉管理器里更改样式</p>
CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(TestStyle));
CDockingManager::SetDockingMode(DT_SMART);</pre>
5、类似的功能都可以进行重新进行继承封装。
6、CDrawingManager实现渐变色的绘制也是非常好的哦!</p>
美化效果:
例子下载
void CMainFrame::OnApplicationLook(UINT id) { CWaitCursor wait; theApp.m_nAppLook = id; switch (theApp.m_nAppLook) { case ID_VIEW_APPLOOK_WIN_2000: CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManager)); break; case ID_VIEW_APPLOOK_OFF_XP: CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOfficeXP)); break; case ID_VIEW_APPLOOK_WIN_XP: CMFCVisualManagerWindows::m_b3DTabsXPTheme = TRUE; CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows)); break; case ID_VIEW_APPLOOK_OFF_2003: CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOffice2003)); CDockingManager::SetDockingMode(DT_SMART); break; case ID_VIEW_APPLOOK_VS_2005: CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerVS2005)); CDockingManager::SetDockingMode(DT_SMART); break; case ID_VIEW_APPLOOK_VS_2008: CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerVS2008)); CDockingManager::SetDockingMode(DT_SMART); break; case ID_VIEW_APPLOOK_WINDOWS_7: CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows7)); CDockingManager::SetDockingMode(DT_SMART); break; default: switch (theApp.m_nAppLook) { case ID_VIEW_APPLOOK_OFF_2007_BLUE: CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_LunaBlue); break; case ID_VIEW_APPLOOK_OFF_2007_BLACK: CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_ObsidianBlack); break; case ID_VIEW_APPLOOK_OFF_2007_SILVER: CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_Silver); break; case ID_VIEW_APPLOOK_OFF_2007_AQUA: CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_Aqua); break; } CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOffice2007)); CDockingManager::SetDockingMode(DT_SMART); } RedrawWindow(NULL, NULL, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW | RDW_FRAME | RDW_ERASE); theApp.WriteInt(_T("ApplicationLook"), theApp.m_nAppLook); }
就以CMFCVisualManagerOffice2007 风格为例,这个类提供了很强大的界面框架美化结构,包含到每一个按钮,每一个容器,甚至是每一个图标。但是很不幸,里面的样式内容微软进行了封装,不允许用户进行改变。但是与其我们一张一张贴图,重绘,废了半天劲,可能还达不到预期的效果,为什么不能模仿微软自带的样式进行继承一个新的界面库呢?
CMFCVisualManagerOffice2007 类的界面背景主要由OnFillBarBackground函数进行填充绘制,其他工具栏、菜单栏、状态栏等等的重绘都对应着一个类似的函数。颜色管理主要由OnUpdateSystemColors函数进行管理。进行编写界面库前,必须深入的了解CMFCVisualManagerOffice2007 类的工作原理,继承过程,消息机制等要点。其他其他VS自带样式类似,不管是CMFCVisualManagerOffice2007或者CMFCVisualManagerOffice2003或者XP都是继承一个基类来完成。如果了解了这些,编写一个对应的界面库就不成问题了吧!
1、DEMO具体操作:
1、新建类,基类为CMFCVisualManagerOffice2007。</p>
2、声明要继承的虚函数,如virtual void OnUpdateSystemColors();</p>
3、重写对应函数,如:实现标题栏TITLE居左或者居中,(PS:再也不用重绘标题栏了吧!)</p>
void TestStyle::OnUpdateSystemColors()
{
CMFCVisualManagerOffice2007::OnUpdateSystemColors();
CMFCVisualManagerOffice2007::m_bNcTextCenter = FALSE;//标题栏Title 居左。TRUE:居中
}
4、视觉管理器里更改样式</p>
CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(TestStyle));
CDockingManager::SetDockingMode(DT_SMART);</pre>
5、类似的功能都可以进行重新进行继承封装。
6、CDrawingManager实现渐变色的绘制也是非常好的哦!</p>
美化效果:
例子下载
相关文章推荐
- MFC MDI和SDI非客户区框架界面美化之----标题栏以及边框美化
- MFC MDI和SDI非客户区框架界面美化之----标题栏以及边框美化
- MFC MDI和SDI美化----之客户区美化
- VC之美化界面(内容覆盖十分全面,经典)
- VC之美化界面(内容覆盖十分全面,经典)
- Winform开发框架之客户关系管理系统(CRM)的开发总结系列1-界面功能展示
- SDI和MDI程序中对非客户区(标题栏、左右下边界)的美化
- 如何刷新SDI框架非客户区
- 问一个获取主框架客户区大小的问题 - VC/MFC / 界面
- VC之美化界面(内容覆盖十分全面,经典)
- VC之美化界面(内容覆盖十分全面,经典)
- MFC MDI和SDI美化----之客户区美化
- VC之美化界面(内容覆盖十分全面,经典)
- SDI模型中根据客户区(视图)大小调整框架
- 注册与登录界面的美化
- 基于Extjs的web表单设计器 第六节——界面框架设计
- 他山界面开发框架OHUI v1.9.1_1
- 全面介绍Android的MVVM框架 - 数据绑定
- 国内开源项目Dcloud中的html5+ sdk,界面框架mui和开发工具hbuilder
- Android图片加载框架最全解析(八),带你全面了解Glide 4的用法