项目类型: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)进行的. 当打开一个 ...
随机推荐
- 双系统 fedora 恢复引导
因为硬盘坏了,所以买了个固态的用用. 先装windows,再装fedora及常用必备的驱动软件装上. 快要完成了心情都挺好,可是在一次关机时window7关机很慢一直在删索引,我嫌时间太长,直接按电源 ...
- PHPCMS v9 超级安全防范教程!
一.目录权限设置很重要:可以有效防范黑客上传木马文件.如果通过 chmod 644 * -R 的话,php文件就没有权限访问了.如果通过chmod 755 * -R 的话,php文件的权限就高了. 所 ...
- Visual Studio 在调试时启用编辑功能
Visual Studio边调试边修改 如果你在调试一个web应用程序的时候,想进行编辑,可以有如下两种方法: 方法一:在web项目的属性页里的web标签页,选中"启用编辑并继续&qu ...
- Unity上一页下一页切换功能实现源码(仅供参考)
在做项目时我们有时需要实现切换上一页下一页图片,切换上一首下一首歌曲等等类似的功能.这里写了个简单的实现源码(仅供参考),要是有更好的方法欢迎提出来,共同进步~ 以切换上一页下一页图片为例: usin ...
- dependencies 和 devDependencies
npm install node_module –save自动更新dependencies字段值 npm install node_module –save-dev自动更新devDependencie ...
- HTTP 协议详解
相关文章:HTTP 协议之压缩 当今web程序的开发技术真是百家争鸣,ASP.NET, PHP, JSP,Perl, AJAX 等等. 无论Web技术在未来如何发展,理解Web程序之间通信的基本协议相 ...
- MVC部分视图含义
Partail Views 类似于ASPX视图引擎中的用户控件,使用部分视图可以创建放置于不同页面的通用部分.
- (转)Java:按值传递和按引用传递详细解说
值传递和引用传递详解: 1:按值传递是什么 指的是在方法调用时,传递的参数是按值的拷贝传递.示例如下: public class TempTest { private void test1(int a ...
- jQuery MiniUI开发系列之:创建组件对象
jQuery MiniUI可以使用Javascript和Html两种方式来创建对象. 1)Javascript创建对象 使用JavaScript创建对象,是最基本的方式,有如下几个要点: 1)使用ne ...
- 详解rsync算法--如何减少同步文件时的网络传输量
先看下图中的场景,客户端A和B,以及服务器server都保存了同一个文件,最初,A.B和server上的文件内容都是相同的(记为File.1).某一时刻,B修改了文件内容,上传到SERVER上(记为F ...