Dui学习笔记

来源:互联网 发布:网络丢包测试软件 编辑:程序博客网 时间:2024/06/06 02:54
#pragma once#include <UIlib.h>using namespace DuiLib;#ifdef _DEBUG#pragma comment(lib, "DuiLib_d.lib")#else#pragma comment(lib, "DuiLib.lib")#endifclass CDuiFrame :public CWindowWnd, public INotifyUI{public:virtual LPCTSTR GetWindowClassName() const { return _T("框架测试"); }virtual void Notify(TNotifyUI &msg)//消息处理在这里{if (msg.sType == _T("click"))//判断是不是单机消息{if (msg.pSender->GetName() == _T("Btn1")){::MessageBox(NULL, _T("我是按钮"), _T("被单击了"), NULL);}}}virtual LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam){LRESULT lRes = 0;if (uMsg == WM_CREATE){CControlUI*pBtn = new CButtonUI;//创建一个按钮类pBtn->SetName(_T("Btn1"));pBtn->SetText(_T("测试窗口演示"));//设置标题pBtn->SetBkColor(0xFF00FF00);//设置背景颜色m_PaintManager.Init(m_hWnd);m_PaintManager.SetInitSize(500,300);m_PaintManager.AttachDialog(pBtn);m_PaintManager.AddNotifier(this);//添加消息响应return lRes;}else if (uMsg == WM_NCACTIVATE){if (!::IsIconic(m_hWnd)){return (wParam == 0) ? TRUE : FALSE;}}else if (uMsg == WM_NCCALCSIZE){return 0;}else if (uMsg == WM_NCPAINT){return 0;}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);CDuiFrame duiFrame;duiFrame.Create(NULL, _T("我的窗口DUI程序"), UI_WNDSTYLE_FRAME, WS_EX_WINDOWEDGE);duiFrame.ShowModal();return 0;}


原创粉丝点击