duilib学习笔记01:一个简单的Duilib程序的基本框架
// 一个简单的Duilib程序的基本框架
// Duilib使用设置部分 #pragma once #define WIN32_LEAN_AND_MEAN #define _CRT_SECURE_NO_DEPRECATE #include <windows.h> #include <objbase.h> #include "..\DuiLib\UIlib.h" using namespace DuiLib; #ifdef _DEBUG # ifdef _UNICODE # pragma comment(lib, "..\\bin\\DuiLib_ud.lib") # else # pragma comment(lib, "..\\bin\\DuiLib_d.lib") # endif #else # ifdef _UNICODE # pragma comment(lib, "..\\bin\\DuiLib_u.lib") # else # pragma comment(lib, "..\\bin\\DuiLib.lib") # endif #endif // 窗口实例及消息响应部分 class CFrameWindowWnd : public CWindowWnd, public INotifyUI { public: CFrameWindowWnd() { }; LPCTSTR GetWindowClassName() const { return _T("UIMainFrame"); }; UINT GetClassStyle() const { return UI_CLASSSTYLE_FRAME | CS_DBLCLKS; }; void OnFinalMessage(HWND /*hWnd*/) { delete this; }; void Notify(TNotifyUI& msg) { if( msg.sType == _T("click") ) { if( msg.pSender->GetName() == _T("closebtn") ) { Close(); } } } LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) { if( uMsg == WM_CREATE ) { m_pm.Init(m_hWnd); CControlUI *pButton = new CButtonUI; pButton->SetName(_T("closebtn")); pButton->SetBkColor(0xFFFF0000); m_pm.AttachDialog(pButton); m_pm.AddNotifier(this); return 0; } else if( uMsg == WM_DESTROY ) { ::PostQuitMessage(0); } LRESULT lRes = 0; if( m_pm.MessageHandler(uMsg, wParam, lParam, lRes) ) return lRes; return CWindowWnd::HandleMessage(uMsg, wParam, lParam); } public: CPaintManagerUI m_pm; }; // 程序入口及Duilib初始化部分 int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*lpCmdLine*/, int nCmdShow) { CPaintManagerUI::SetInstance(hInstance); CPaintManagerUI::SetResourcePath(CPaintManagerUI::GetInstancePath()); CFrameWindowWnd* pFrame = new CFrameWindowWnd(); if( pFrame == NULL ) return 0; pFrame->Create(NULL, _T("测试"), UI_WNDSTYLE_FRAME, WS_EX_WINDOWEDGE); pFrame->ShowWindow(true); CPaintManagerUI::MessageLoop(); return 0; }
--------------------------------------------------------------------------------------------
posted on 2012-11-22 16:08 xuejianhui 阅读(1101) 评论(0) 编辑 收藏 举报