项目类型:MFC
XproerUI结构:
3rd 第三方库目录
cximage
dll 编译的DLL目录
pugixml-1.4
lib 编译的LIB目录
zlib-1.2.8
dll 编译的DLL目录
XproerUI UI引擎库目录
dll 编译的DLL目录
Resource
Xproer.Com
Xproer.Drawing
Xproer.Forms
Xproer.Manager
Xproer.UI
Xproer.UI.Controls
Xproer.UI.WinControls
1.1.1. 下载相关资源
1.1.2. 设置头文件路径和链接库路径
说明:建议将项目文件夹和XproerUI放在同级目录下
示例结构:
3rd 第三方库目录
AppUI XproerUI库目录
AppUtils Xproer工具库目录
demo 自已的工程目录
使用上面的目录结构可以直接使用下面的头文件和链接库配置代码(在Debug和Release模式下通用):
头文件:
.\
..\3rd\pugixml-1.4\src
..\3rd\cximage\CxImage
..\3rd\zlib-1.2.8
..\AppUtils
合并:
.\;..\3rd\pugixml-1.4\src;..\3rd\cximage\CxImage;..\3rd\zlib-1.2.8;..\AppUtils;
链接库(MD):
..\3rd\pugixml-1.4\lib\$(ConfigurationName)\
..\3rd\cximage\dll\Unicode $(ConfigurationName)\
..\3rd\zlib-1.2.8\dll\$(ConfigurationName)\
..\AppUtils\
%(AdditionalLibraryDirectories)
合并:
..\3rd\pugixml-1.4\lib\$(ConfigurationName)\;..\3rd\cximage\dll\Unicode $(ConfigurationName)\;..\3rd\zlib-1.2.8\dll\$(ConfigurationName)\;..\AppUtils\dll\$(ConfigurationName)\;%(AdditionalLibraryDirectories)
附加包含目录截图:
链接器配置截图:
1.1.3. 在项目的stdafx.h中增加头文件
XproerUI提供了UIHead.h文件,在项目中只需要包含此文件即可。
// stdafx.h : 标准系统包含文件的包含文件,
// 或是经常使用但不常更改的
// 特定于项目的包含文件
#pragmaonce
#ifndefVC_EXTRALEAN
#defineVC_EXTRALEAN // 从 Windows 头中排除极少使用的资料
#endif
#include"targetver.h"
#define_ATL_CSTRING_EXPLICIT_CONSTRUCTORS // 某些 CString 构造函数将是显式的
// 关闭 MFC 对某些常见但经常可放心忽略的警告消息的隐藏
#define_AFX_ALL_WARNINGS
#include<afxwin.h> // MFC 核心组件和标准组件
#include<afxext.h> // MFC 扩展
#include<afxdisp.h> // MFC 自动化类
#ifndef _AFX_NO_OLE_SUPPORT
#include<afxdtctl.h> // MFC 对 Internet Explorer 4 公共控件的支持
#endif
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include<afxcmn.h> // MFC 对 Windows 公共控件的支持
#endif// _AFX_NO_AFXCMN_SUPPORT
#include<afxcontrolbars.h> // 功能区和控件条的 MFC 支持
#include"UIHead.h"
#ifdef_UNICODE
#ifdefined _M_IX86
#pragmacomment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
#elifdefined _M_X64
#pragmacomment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
#else
#pragmacomment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#endif
#endif
说明:在UIHead.h中自动包含了boost,AppUtils,XproerUI.lib,zlib,cximage,pugixml等文件和lib
UIHead.h文件代码如下:
#pragmawarning(disable:4150) //
#pragmawarning(disable:4251) //
#pragmawarning(disable:4275) //
#include"afxtoolbar.h"
#include"afxmenubar.h"
#include"afxtoolbarmenubutton.h"
#include<gdiplus.h>
#include"Richole.h"
#include"Richedit.h"
#include"shellapi.h"
#include"Usp10.h"
#include<ctime>
usingnamespaceGdiplus;
#include"atlutil.h"
#include<vector>
#include<list>
#include<map>
#include<algorithm>
#include<fstream>
#include<iostream>
#include<string>
#include<array>
#include<memory>
usingnamespacestd;
#include<boost/foreach.hpp>
#include<boost/typeof/typeof.hpp>
#include<boost/shared_array.hpp>
#include<boost/smart_ptr.hpp>
#include<boost/any.hpp>
#include<boost/variant.hpp>
#include<boost/bimap.hpp>
#include<boost/filesystem.hpp>
#include<boost/format.hpp>
#include<boost/assert.hpp>
#include<boost/assign.hpp>
#include<boost/random.hpp>
#include<boost/algorithm/string.hpp>
#include<boost/pool/detail/singleton.hpp>
#include<boost/date_time/gregorian/gregorian.hpp>
#include<boost/date_time/posix_time/posix_time.hpp>
#defineBOOST_ALL_NO_LIB
#defineBOOST_DATE_TIME_SOURCE
#defineforeachBOOST_FOREACH
#definereverse_foreachBOOST_REVERSE_FOREACH
usingnamespaceboost;
usingnamespaceboost::assign;
usingnamespaceboost::gregorian;
usingnamespaceboost::posix_time;
usingnamespaceboost::filesystem;
namespacefs = boost::filesystem;
usingboost::details::pool::singleton_default;
#include"ximage.h"
#include"sigslot.h"
#include"pugiconfig.hpp"
#include"pugixml.hpp"
#include"contrib/minizip/zip.h"
#include"contrib/minizip/unzip.h"
usingnamespacepugi;
#include"sigslot.h"
#include"AppUI.h"
#include"AppUICfg.h"
#include"AppUtilsCfg.h"
#include"Resource/IResource.h"
#include"Xproer.Drawing/GdiTool.h"
#include"ximage.h"
#include"Xproer.Drawing/CxImageTool.h"
#include"Xproer.Drawing/CombinImage.h"
#include"Xproer.Drawing/CombinImageX.h"
#include"Xproer.Drawing/TileImage.h"
#include"Xproer.Drawing/TileImageX.h"
#include"xproer.Drawing/MemoryDC.h"
#include"xproer.Manager/ResMgr.h"
#include"Xproer.Manager/ColorMgr.h"
#include"xproer.Manager/FontMgr.h"
#include"xproer.Manager/ImageMgr.h"
#include"xproer.Manager/PopMenuMgr.h"
#include"Xproer.Manager/StyleManager.h"
#include"xproer.Manager/ImageCfg.h"
#include"xproer.Manager/ToolBarMgr.h"
#include"Xproer.Forms/DialogBase.h"
#include"Xproer.UI/ArgsManager.h"
#include"Xproer.UI/Styles.h"
#include"Xproer.UI/IDSigner.h"
#include"Xproer.UI/CtrlIDMaker.h"
#include"Xproer.UI/DUIControl.h"
#include"Xproer.UI.Controls/Button.h"
#include"Utility/Encoder.h"
#include"Utility/Convert.h"
#include"IO/Directory.h"
#include"System/Screen.h"
usingnamespaceXproer::Manager;
usingnamespaceXproer::System;
usingnamespaceXproer::Drawing;
usingnamespaceXproer::UI;
usingnamespaceXproer::UI::Controls;
usingnamespaceXproer::Forms;
usingnamespaceAppUtils::Utility;
usingnamespaceAppUtils::IO;
#pragmacomment(lib, "Usp10.lib")
#pragmacomment(lib, "cximage.lib")
#pragmacomment(lib, "gdiplus.lib")
#pragmacomment(lib, "pugixml.lib")
#pragmacomment(lib, "zlib.lib")
#pragmacomment(lib, "AppUtils.lib")
#pragmacomment(lib, "XproerUI.lib")
#ifdef_DEBUG
#pragmacomment(lib, "libboost_date_time-vc100-mt-1_55.lib")
#pragmacomment(lib, "libboost_system-vc100-mt-gd-1_55.lib")
#pragmacomment(lib, "libboost_filesystem-vc100-mt-gd-1_55.lib")
#else
#pragmacomment(lib, "libboost_date_time-vc100-mt-1_55.lib")
#pragmacomment(lib, "libboost_system-vc100-mt-1_55.lib")
#pragmacomment(lib, "libboost_filesystem-vc100-mt-1_55.lib")
#endif
2.将项目运行库改为MD
修改Release模式的运行库:
1.1.4. 在InitInstance中初始化UI库
BOOLCmfcDemoApp::InitInstance()
{
// 如果一个运行在 Windows XP 上的应用程序清单指定要
// 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式,
//则需要 InitCommonControlsEx()。 否则,将无法创建窗口。
INITCOMMONCONTROLSEXInitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
// 将它设置为包括所有要在应用程序中使用的
// 公共控件类。
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);
CWinApp::InitInstance();
AfxEnableControlContainer();
// 创建 shell 管理器,以防对话框包含
// 任何 shell 树视图控件或 shell 列表视图控件。
CShellManager *pShellManager = newCShellManager;
// 激活“Windows Native”视觉管理器,以便在 MFC 控件中启用主题
CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows));
// 标准初始化
// 如果未使用这些功能并希望减小
// 最终可执行文件的大小,则应移除下列
// 不需要的特定初始化例程
// 更改用于存储设置的注册表项
// TODO: 应适当修改该字符串,
// 例如修改为公司或组织名
SetRegistryKey(_T("应用程序向导生成的本地应用程序"));
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
//初始化UI库
LoadAppTheme(L"skin.zip");//skin.zip需要和主程序放在一起
CmfcDemoDlgdlg;
m_pMainWnd = &dlg;
INT_PTRnResponse = dlg.DoModal();
if (nResponse == IDOK)
{
}
elseif (nResponse == IDCANCEL)
{
}
elseif (nResponse == -1)
{
TRACE(traceAppMsg, 0, "警告: 对话框创建失败,应用程序将意外终止。\n");
TRACE(traceAppMsg, 0, "警告: 如果您在对话框上使用 MFC 控件,则无法 #define _AFX_NO_MFC_CONTROLS_IN_DIALOGS。\n");
}
// 删除上面创建的 shell 管理器。
if (pShellManager != NULL)
{
deletepShellManager;
}
returnFALSE;
}
在应用程序退出时卸载皮肤和GDI+
intCmfcDemoApp::ExitInstance()
{
UnLoadTheme();
//卸载GDI+
GdiplusShutdown(gdiplusToken);
returnCWinApp::ExitInstance();
}
1.1.5. 修改主窗口代码
1.继承FormMsgHandler
#pragmaonce
// CmfcDemoDlg 对话框
classCmfcDemoDlg
: publicCDialogEx
, publicFormMsgHandler
{
// 构造
public:
CmfcDemoDlg(CWnd* pParent = NULL); // 标准构造函数
virtualLRESULTWindowProc(UINTmessage, WPARAMwParam, LPARAMlParam);
//dui
virtualvoidInitControls();
//event
voidbtnCancle_click(ControlBase* sender);
private:
Button* m_btnCancel;//退出按钮
// 对话框数据
enum { IDD = IDD_MFCDEMO_DIALOG };
protected:
virtualvoidDoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
// 实现
protected:
HICONm_hIcon;
// 生成的消息映射函数
virtualBOOLOnInitDialog();
afx_msgvoidOnSysCommand(UINTnID, LPARAMlParam);
afx_msgHCURSOROnQueryDragIcon();
DECLARE_MESSAGE_MAP()
};
2.重载WindowProc方法,将消息转发到UI引擎
LRESULTCmfcDemoDlg::WindowProc(UINTmessage, WPARAMwParam, LPARAMlParam)
{
BOOLhd = FALSE;
if (this->isWmMsg(message))
{
returnthis->wmMsgMap(message, wParam, lParam,hd);
}
returnCDialogEx::WindowProc(message, wParam, lParam);
}
3.在OnInitDialog中初始化UI资源
BOOLCmfcDemoDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
// 将“关于...”菜单项添加到系统菜单中。
// IDM_ABOUTBOX 必须在系统命令范围内。
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
BOOLbNameValid;
CStringstrAboutMenu;
bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
ASSERT(bNameValid);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// 设置此对话框的图标。 当应用程序主窗口不是对话框时,框架将自动
// 执行此操作
SetIcon(m_hIcon, TRUE); // 设置大图标
SetIcon(m_hIcon, FALSE); // 设置小图标
// 加载UI资源
this->init(this, L"demo.xml");
returnTRUE; // 除非将焦点设置到控件,否则返回 TRUE
}
4.在InitControls中获取控件并与成员变量关联
voidCmfcDemoDlg::InitControls()
{
this->m_btnCancel = (Button*)this->find(L"button2");
this->m_btnCancel->Click.connect(this, &CmfcDemoDlg::btnCancle_click);
}
5.编写控件事件
voidCmfcDemoDlg::btnCancle_click(ControlBase* sender)
{
TRACE("btnCancle_click \n");
this->EndDialog(1);
}
- 如何使用XproerUI库(WTL)-XproerUI界面库教程
版权所有 2009-2015 荆门泽优软件有限公司 保留所有权利 产品首页:http://www.ncmem.com/apps/xproerui/index.asp 开发文档(SkinStudio): ...
- 新建一个UI窗口-XproerUI(MFC)教程
版权所有 2009-2015 荆门泽优软件有限公司 保留所有权利 产品首页:http://www.ncmem.com/apps/xproerui/index.asp 在线文档(XproerUI):Xp ...
- 如何在属性面板中增加一个属性-UI界面编辑器(XproerUI)教程
版权所有 2009-2015 荆门泽优软件有限公司 保留所有权利 产品首页:http://www.ncmem.com/apps/xproerui/index.asp 开发文档(SkinStudio): ...
- XproerIM V2开源,基于XproerUI引擎构架
资源下载:XproerIM源代码(访问密码:2e47),imServer(访问密码 364c), 技术交流群:6259765 技术支持:3040217208 咨询邮箱:2190615607@qq.co ...
- 菜鸟Python学习笔记第一天:关于一些函数库的使用
2017年1月3日 星期二 大一学习一门新的计算机语言真的很难,有时候连函数拼写出错查错都能查半天,没办法,谁让我英语太渣. 关于计算机语言的学习我想还是从C语言学习开始为好,Python有很多语言的 ...
- TinyWeb v1.0 正式完成第一个Release版本(功能基于 libuv 跨平台库)
使用方法很简单,很容易融入现有项目,使现有项目拥有Web网站功能和WebSocket,以及Socket直连! 并且包含了一个跨平台(windows/linux)工具集合; 嗯,也挺棒的^,^ 在项目中 ...
- 在 Laravel 中使用图片处理库 Integration/Image
系统需求 PHP >= 5.3 Fileinfo Extension GD Library (>=2.0) … or … Imagick PHP extension (>=6.5.7 ...
- [APUE]标准IO库(下)
一.标准IO的效率 对比以下四个程序的用户CPU.系统CPU与时钟时间对比 程序1:系统IO 程序2:标准IO getc版本 程序3:标准IO fgets版本 结果: [注:该表截取自APUE,上表中 ...
- [APUE]标准IO库(上)
一.流和FILE对象 系统IO都是针对文件描述符,当打开一个文件时,即返回一个文件描述符,然后用该文件描述符来进行下面的操作,而对于标准IO库,它们的操作则是围绕流(stream)进行的. 当打开一个 ...
随机推荐
- 【linux】之相关命令
防火墙 ) 重启后生效 开启: chkconfig iptables on 关闭: chkconfig iptables off ) 即时生效,重启后失效 开启: service iptables s ...
- IOCP和WSA异步协同客户端版
有些小伙伴看了之前发的WIN平台下IOCP和WSA异步协同处理SOCKET后有些疑惑,所以就画了个简易流程图+架构图发上来给小伙伴参考 简单说,WSA异步控制CONNECT,IOCP控制WSASend ...
- JQuery 1.*速成版之二
过滤选择器简称:过滤器.它其实也是一种选择器,而这种选择器类似与 CSS3(http://t.mb5u.com/css3/)里的伪类,可以让不支持 CSS3 的低版本浏览器也能支持.和常规选择器一样, ...
- Using dojo/query(翻译)
In this tutorial, we will learn about DOM querying and how the dojo/query module allows you to easil ...
- Oracle 支持在具有 DHCP 分配的 IP 地址的系统上进行安装
今天在安装Oracle 10g的时候,遇到了“ Oracle 支持在具有 DHCP 分配的 IP 地址的系统上进行安装” 这个问题,经过搜索,找到了解决方案,具体如下: win7下右键单机" ...
- 【学】React的学习之旅2 - React Component的生命周期
分成三个状态: Mounted Update Unmounted Mounted:当我们看到组件在浏览器中从无到有的效果的时候,mounted已经结束了,这个组件已经被mounted了 有这个阶段有2 ...
- javascript 要点
javascript 要点 1 JavaScript:写入 HTML 输出 document.write("<h1>This is a heading</h1>&qu ...
- PBR实现2.0
之前的错误和欠缺 1. 过于简单的划分diffuse和specular,非常光滑的非金属材料也是很能反光的2. 费奈尔效应的处理,F0的选取也比较随意3. 没有GI,更不支持AO 正确划分diffus ...
- 修改eclipse中包的显示结构为树形
- MyEclipse中代码格式化后自动换行
MyEclipse的默认设置里面各种坑人,怎么不方便怎么设置,用户体验差到极点.今天又遇到个问题,按下Ctrl + Shift + F 后,自动格式化后的代码原来只有一行,结果变成了3行,看着都想吐. ...