DuiLib学习(一)
2016-06-24 18:12
351 查看
教程: http://www.cnblogs.com/Alberl/p/3343579.html
这个是邓学彬的博客 Duilib 导航帖:http://blog.csdn.net/cometnet/article/details/12448339
看了这个教程还是有那么一点蛋疼,就是老提示下面这个错误。
不过已经解决了,在包含 UIlib.h 之前包含 ObjBase.h 即可。
我的解决方案名字叫 test2。
stdafx.h:
test2.cpp:
效果图:
总结:
stdafx.h 中 包含 ObjBase.h 和 UIlib.h 并且 链接 lib 库
test2.cpp 中 新建一个 class 继承 CWindowWnd 和 接口类 INotifyUI 。
知识点:
①GetWindowClassName 后面的const 表明这个函数只是一个只读函数,返回的值为窗口类名。
②Notify为通告消息处理函数。
③HandleMessage为窗口消息处理函数。
④CPaintManagerUI为UI管理类,HelloWord中整个绿色区域为一个CButtonUI
这个是邓学彬的博客 Duilib 导航帖:http://blog.csdn.net/cometnet/article/details/12448339
看了这个教程还是有那么一点蛋疼,就是老提示下面这个错误。
不过已经解决了,在包含 UIlib.h 之前包含 ObjBase.h 即可。
我的解决方案名字叫 test2。
stdafx.h:
// stdafx.h : 标准系统包含文件的包含文件, // 或是经常使用但不常更改的 // 特定于项目的包含文件 // #pragma once #include "targetver.h" #define WIN32_LEAN_AND_MEAN // 从 Windows 头中排除极少使用的资料 // Windows 头文件: #include <windows.h> // C 运行时头文件 #include <stdlib.h> #include <malloc.h> #include <memory.h> #include <tchar.h> // TODO: 在此处引用程序需要的其他头文件 #include <ObjBase.h> #include <UIlib.h> using namespace DuiLib; #ifdef _DEBUG # ifdef _UNICODE # pragma comment(lib, "DuiLib_ud.lib") # else # pragma comment(lib, "DuiLib_d.lib") # endif #else # ifdef _UNICODE # pragma comment(lib, "DuiLib_u.lib") # else # pragma comment(lib, "DuiLib.lib") # endif #endif
test2.cpp:
// test2.cpp : 定义应用程序的入口点。 // #include "stdafx.h" #include "test2.h" class CDuiFrameWnd : public CWindowWnd, public INotifyUI { public: virtual LPCTSTR GetWindowClassName() const { return _T("DUIMainFrame"); } virtual void Notify(TNotifyUI& msg) {} virtual LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) { LRESULT lRes = 0; if( uMsg == WM_CREATE ) { CControlUI *pWnd = new CButtonUI; pWnd->SetText(_T("Hello World")); // 设置文字 pWnd->SetBkColor(0xFF00FF00); // 设置背景色 m_PaintManager.Init(m_hWnd); m_PaintManager.AttachDialog(pWnd); return lRes; } if( m_PaintManager.MessageHandler(uMsg, wParam, lParam, lRes) ) { return lRes; } return __super::HandleMessage(uMsg, wParam, lParam); } protected: CPaintManagerUI m_PaintManager; }; int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { CPaintManagerUI::SetInstance(hInstance); CDuiFrameWnd duiFrame; duiFrame.Create(NULL, _T("DUIWnd"), UI_WNDSTYLE_FRAME, WS_EX_WINDOWEDGE); duiFrame.ShowModal(); return 0; }
效果图:
总结:
stdafx.h 中 包含 ObjBase.h 和 UIlib.h 并且 链接 lib 库
test2.cpp 中 新建一个 class 继承 CWindowWnd 和 接口类 INotifyUI 。
知识点:
①GetWindowClassName 后面的const 表明这个函数只是一个只读函数,返回的值为窗口类名。
②Notify为通告消息处理函数。
③HandleMessage为窗口消息处理函数。
④CPaintManagerUI为UI管理类,HelloWord中整个绿色区域为一个CButtonUI
相关文章推荐
- iOS UIViewAnimationOptions类型
- /**切控件圆角 设置边框*/
- uisearchbar支持空搜索
- UILabel 多行显示<自动换行>
- (java)request.getParameterMap()
- 413 Request Entity Too Large
- iOS教你轻松打造瀑布流Layout-最好的UICollectionViewDemo
- UIBarButtonItem 自定义 RightBarButtonItem
- ImportError: No module named requests
- Android开发,关于一些我没用过,突然知道后相见恨晚的UI组件
- 关于UIScrollView的几点总结
- 解决被依赖module中BuildConfig.DEBUG的值总为false问题
- iOS开发之交互测试/UI Test
- 前台JSON后台接收的时候,转变为对象的要求@resquestBody的使用
- 欧洲杯 2016 高清直播 - 观看工具 UEFA-EURO-2016-Play.7z
- android自定义toolbar的menuItem图标大小
- Sketch 快捷键速记表(中英对照)
- org.hibernate.service.UnknownServiceException: Unknown service requested [org.hibernate.stat.spi.Sta
- Xcode的Architectures、Valid Architectures和Build Active Architecture Only属性
- UILabel 的使用