Prof-UIS是一个功能丰富的MFC扩展库,能够为您的Windows应用程序提供专业和友好的用户界面。Prof-UIS带有完整的源代码,一套示例,CHM帮助。当前免费版本是2.92,是为任何非商业用途免费的。
下载地址: http://www.prof-uis.com/download/mfc.aspx
下面介绍下Prof-UIS免费版的安装:
1.解压压缩包到文件夹,进入" ...\Prof-UIS\Workspace"文件夹;
2.运行 Visual Studio 2008 SP1打开" ...\Prof-UIS\Workspace\ProfUIS_900.sln"解决方案;
3.在工具栏上,可以看到有多种解决方案配置,大部分情况下,我们都需要至少两种配置方案,一种Debug配置,一种Release配置,在这里我先选择" Static Unicode Debug",如下所示:
4.因为Prof-UIS有引用到 ZLib和 LibPNG库,所以得先编译下这两个库,确认这两个库项目的配置为" Used LIBs Debug (LIB CRT)",这是静态库调试版本,编译完后就会在" ...\Prof-UIS\Bin_900"文件夹生成" ZLibLIBCRT-d.lib"和" LibPNGLIBCRT-d.lib"两个文件;
5.接下去,编译" ProfSkinLIB"项目,生成" ProfSkin292sud.lib"文件;
5.最后,编译" ProfUISLIB"项目,生成" ProfUIS292sud.lib"文件;
6.接下去想要编译示例工程,VS就会崩溃,网上查了下资料,发现是资源文件" resource.rc"的问题,打开" resource.rc"文件,删除 除"English (U.S.) resources"、"Chinese (P.R.C.) resources"和"Chinese (Taiwan) resources" 之外的其他语言,剩余其他代码如下:
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/
#undef APSTUDIO_READONLY_SYMBOLS
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
/
//
// CSS
//
IDR_EXT_DEFAULT_CSS CSS DISCARDABLE "Resources\\CSS\\IDR_EXT_DEFAULT_CSS.css"
#endif // English (U.S.) resources
/
//#define __EXT_MFC_NO_RESOURCES_ARABIC_SAUDI_ARABIA
//#define __EXT_MFC_NO_RESOURCES_BELARUSIAN
//#define __EXT_MFC_NO_RESOURCES_BULGARIAN_DEFAULT
//#define __EXT_MFC_NO_RESOURCES_CHINESE_SIMPLIFIED
//#define __EXT_MFC_NO_RESOURCES_CHINESE_TRADITIONAL
//#define __EXT_MFC_NO_RESOURCES_CROATIAN_DEFAULT
//#define __EXT_MFC_NO_RESOURCES_CZECH_DEFAULT
//#define __EXT_MFC_NO_RESOURCES_DANISH_DEFAULT
//#define __EXT_MFC_NO_RESOURCES_DUTCH_NETHERLANDS
//#define __EXT_MFC_NO_RESOURCES_ESTONIAN
//#define __EXT_MFC_NO_RESOURCES_GERMAN
//#define __EXT_MFC_NO_RESOURCES_GREEK
//#define __EXT_MFC_NO_RESOURCES_HUNGARIAN_DEFAULT
//#define __EXT_MFC_NO_RESOURCES_FRENCH
//#define __EXT_MFC_NO_RESOURCES_FRENCH_CANADIAN
//#define __EXT_MFC_NO_RESOURCES_INDONESIAN
//#define __EXT_MFC_NO_RESOURCES_ITALIAN
//#define __EXT_MFC_NO_RESOURCES_JAPANESE_DEFAULT
//#define __EXT_MFC_NO_RESOURCES_KOREAN_DEFAULT
//#define __EXT_MFC_NO_RESOURCES_LATVIAN_DEFAULT
//#define __EXT_MFC_NO_RESOURCES_LITHUANIAN
//#define __EXT_MFC_NO_RESOURCES_NORWEGIAN_BOKMAL
//#define __EXT_MFC_NO_RESOURCES_POLISH_DEFAULT
//#define __EXT_MFC_NO_RESOURCES_PORTUGUESE_BRAZILIAN
//#define __EXT_MFC_NO_RESOURCES_ROMANIAN_DEFAULT
//#define __EXT_MFC_NO_RESOURCES_RUSSIAN_DEFAULT
//#define __EXT_MFC_NO_RESOURCES_SERBIAN_LATIN
//#define __EXT_MFC_NO_RESOURCES_SLOVAK_DEFAULT
//#define __EXT_MFC_NO_RESOURCES_SLOVENIAN_DEFAULT
//#define __EXT_MFC_NO_RESOURCES_SPANISH_MODERN
//#define __EXT_MFC_NO_RESOURCES_SWEDISH_DEFAULT
//#define __EXT_MFC_NO_RESOURCES_TURKISH_DEFAULT
//#define __EXT_MFC_NO_RESOURCES_UKRAINIAN_DEFAULT
/
// Resources for geo controls
#include "ResGeoControls\\ResGeoControls.rc"
/
// Resources for common and shell controls
#include "ResCommonControls\\ResCommonControls.rc"
/
// Resources for Office 2007 paint managers
#include "Res2007\\Res2007.rc"
/
// Resources for Office 2010 paint manager
#include "Res2010office\\Res2010office.rc"
/
// Resources for paint manager switching controls
#include "ResPM\\ResPM.rc"
#if ( !(defined _AFXDLL && !defined __STATPROFUIS_WITH_DLLMFC__) )
#include "AfxPrint.rc"
#endif
/
/
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#include "Resource_enu.rc"
#endif // English (U.S.) resources
/
/
// Chinese (P.R.C.) resources
#ifndef __EXT_MFC_NO_RESOURCES_CHINESE_SIMPLIFIED
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)
#ifdef _WIN32
LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED
#pragma code_page(936)
#endif //_WIN32
#include "Resource_chs.rc"
#endif // Chinese (P.R.C.) resources
#endif // __EXT_MFC_NO_RESOURCES_CHINESE_SIMPLIFIED
/
/
// Chinese (Taiwan) resources
#ifndef __EXT_MFC_NO_RESOURCES_CHINESE_TRADITIONAL
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHT)
#ifdef _WIN32
LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_TRADITIONAL
#pragma code_page(950)
#endif //_WIN32
#include "Resource_cht.rc"
#endif // Chinese (Taiwan) resources
#endif // __EXT_MFC_NO_RESOURCES_CHINESE_TRADITIONAL
/
#ifndef APSTUDIO_INVOKED
/
//
// Generated from the TEXTINCLUDE 3 resource.
//
#define _AFX_NO_SPLITTER_RESOURCES
#define _AFX_NO_OLE_RESOURCES
#define _AFX_NO_TRACKER_RESOURCES
#define _AFX_NO_PROPERTY_RESOURCES
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE 9, 1
#pragma code_page(1252)
#endif //_WIN32
#include "afxres.rc" // Standard components
#endif
/
#endif // not APSTUDIO_INVOKED
7.这时再编译示例工程即可通过,如下图所示:
下面测试如何简单使用:
1.新建基于对话框工程TestProfUI,使用Unicode库,在静态库中使用MFC;
2.项目属性的"C/C++"里"附加包含目录"添加Prof-UIS的"...\Prof-UIS\Include"文件夹路径,警告等级改为"4 级(/W4)","链接器"里"附加库目录"添加"...\Prof-UIS\Bin_900"路径,"资源"里"附加包含目录"添加"...\Prof-UIS\Include"文件夹路径;
3.在项目的"stdafx.h"文件里,添加以下代码:
1 | #include <Prof-UIS.h> |
4.在项目的资源文件"TestProfUI.rc2",右键"查看代码",在下方添加以下代码:
1 | #include <Resources\resource.rc> |
5.把主对话框CTestProfUIDlg的基类CDialog换成CExtNCW < CExtResizableDialog >,代码如下所示:
1 | class CTestProfUIDlg : public CExtNCW < CExtResizableDialog > |
相应的CTestProfUIDlg实现文件也换成CExtNCW < CExtResizableDialog >;
6.在对话框初始化OnInitDialog函数,添加以下内容:
1 | g_PaintManager.InstallPaintManager(RUNTIME_CLASS(CExtPaintManagerOffice2010_R2_Blue)); |
7.编译运行结果如下所示:
8.两个按钮和文本控件都还没有美化成Office2010样式,首先声明它们的变量:
1 2 3 4 |
public: CExtButton m_ok; CExtButton m_cancel; CExtLabel m_tip; |
然后,在实现文件里面绑定控件,代码如下:
1 2 3 4 5 6 7 |
void CTestProfUIDlg::DoDataExchange(CDataExchange* pDX) { CExtNCW < CExtResizableDialog >::DoDataExchange(pDX); DDX_Control(pDX, IDOK, m_ok); DDX_Control(pDX, IDCANCEL, m_cancel); DDX_Control(pDX, IDC_STATIC_TIP, m_tip);//需要改文本控件的ID值为IDC_STATIC_TIP } |
9.接着运行,Windows 7下结果如下所示:
Windows XP下结果如下所示:
10.要减少生成EXE文件的体积大小,可以打开"...\Prof-UIS\Include\Prof-UIS.h",找到类似下面代码的语句,并注释成类似下面样子:
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 |
// optional features (you can also exclude some resources in the resource.rc file) #define __EXT_MFC_NO_PROF_UIS_ABOUT_DIALOG //取消Prof-UIS关于对话框 //#define __EXT_MFC_NO_MDI_WINDOWS_LIST_DIALOG //#define __EXT_MFC_NO_SPLITTER_WND //#define __EXT_MFC_NO_DOCK_MARKERS //#define __EXT_MFC_NO_EXTCONTENTEXPANDWND_H //#define __EXT_MFC_NO_DYNAMIC_BAR_SITE //#define __EXT_MFC_NO_CHECK_LIST //#define __EXT_MFC_NO_SCROLLWND //#define __EXT_MFC_NO_SCROLLCONTAINERWND //#define __EXT_MFC_NO_SCROLLITEMWND //#define __EXT_MFC_NO_SCROLLCONAINERWND //#define __EXT_MFC_NO_SCROLLRICHCONTENTWND //#define __EXT_MFC_NO_RICHCONTENTGENERATORWND //#define __EXT_MFC_NO_SPIN //#define __EXT_MFC_NO_STATUSBAR //#define __EXT_MFC_NO_NC_FRAME //#define __EXT_MFC_NO_PROGRESS_WND #define __EXT_MFC_NO_THEME_SWITCHER_TOOLBAR //取消主题切换工具栏 //#define __EXT_MFC_NO_TREE_VIEW_CTRL //#define __EXT_MFC_NO_LIST_VIEW_CTRL //#define __EXT_MFC_NO_MSG_BOX |
11.注释完需要重新编译库。另一种打开" ...\Prof-UIS\Include\Resources\resource.rc",可以把不需要的资源注释掉,比如注释成下面的语句:
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
/ // Resources for geo controls //#include "ResGeoControls\\ResGeoControls.rc" / // Resources for common and shell controls #include "ResCommonControls\\ResCommonControls.rc" / // Resources for Office 2007 paint managers //#include "Res2007\\Res2007.rc" / // Resources for Office 2010 paint manager #include "Res2010office\\Res2010office.rc" / // Resources for paint manager switching controls //#include "ResPM\\ResPM.rc" |
这将会使得生成的文件减少很大的体积。