当前位置:   article > 正文

c++ duilib简单的例子_c++ ui 库 dul

c++ ui 库 dul
  1. #include "../DuiLib/UIlib.h"
  2. using namespace DuiLib;
  3. #pragma comment(lib,"../lib/DuiLib_d.lib")
  4. class CDuiFrameWnd:public CWindowWnd, public INotifyUI
  5. {
  6. public:
  7. virtual LPCTSTR GetWindowClassName()const { return _T("DUIMainFrame"); }
  8. virtual void Notify(TNotifyUI& msg)
  9. {
  10. if (msg.sType == _T("click"))
  11. {
  12. if (msg.pSender->GetName() == _T("btnHello"));
  13. {
  14. ::MessageBox(NULL, _T("我是按钮"), _T("点击了按钮"), NULL);
  15. }
  16. }
  17. }
  18. virtual LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
  19. {
  20. LRESULT lRes = 0;
  21. if (uMsg == WM_CREATE)
  22. {
  23. CControlUI* pWnd = new CButtonUI;
  24. pWnd->SetName(_T("btnHello"));//设置控件的名称,这个名称用于标识每一个控件,必须唯一,相当于MFC里面的控件ID
  25. pWnd->SetText(_T("Hello World"));//设置文字
  26. pWnd->SetBkColor(0xFF00FF00);//设置背景色
  27. m_PaintManager.Init(m_hWnd);
  28. m_PaintManager.AttachDialog(pWnd);
  29. m_PaintManager.AddNotifier(this);//添加控件等消息响应,这样消息就会传达到duilib的消息循环,我们可以在Notify函数里做消息处理
  30. return lRes;
  31. }
  32. if (m_PaintManager.MessageHandler(uMsg, wParam, lParam, lRes))
  33. {
  34. return lRes;
  35. }
  36. return __super::HandleMessage(uMsg, wParam, lParam);
  37. }
  38. protected:
  39. CPaintManagerUI m_PaintManager;
  40. };
  41. int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
  42. {
  43. CPaintManagerUI::SetInstance(hInstance);
  44. CDuiFrameWnd duiFrame;
  45. duiFrame.Create(NULL, _T("DUIWnd"), UI_WNDSTYLE_FRAME, WS_EX_WINDOWEDGE);
  46. duiFrame.ShowModal();
  47. return 0;
  48. }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/秋刀鱼在做梦/article/detail/942910
推荐阅读
相关标签
  

闽ICP备14008679号