CMessageboxWnd.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #pragma once
  2. #include "../pch/pch.h"
  3. #include "CMainWnd.h"
  4. class CMessageboxWnd : public CWindowWnd, public INotifyUI, public IMessageFilterUI
  5. {
  6. public:
  7. LPCTSTR GetWindowClassName() const
  8. {
  9. return _T("UIMessageboxFrame");
  10. };
  11. UINT GetClassStyle() const
  12. {
  13. return UI_CLASSSTYLE_DIALOG;
  14. };
  15. void OnFinalMessage(HWND /*hWnd*/)
  16. {
  17. //WindowImplBase::OnFinalMessage(hWnd);
  18. m_pm.RemovePreMessageFilter(this);
  19. //delete this;
  20. };
  21. void Init()
  22. {
  23. }
  24. void Notify(TNotifyUI& msg)
  25. {
  26. if(msg.sType == _T("click"))
  27. {
  28. DuiLib::CDuiString senderName = msg.pSender->GetName();
  29. if(senderName == _T("messagebox_dlg_closebtn"))
  30. {
  31. Close(IDCANCEL);
  32. return;
  33. }
  34. }
  35. }
  36. LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  37. {
  38. LONG styleValue = ::GetWindowLong(*this, GWL_STYLE);
  39. styleValue &= ~WS_CAPTION;
  40. ::SetWindowLong(*this, GWL_STYLE, styleValue | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
  41. // 把自己的窗口句柄与窗口绘制管理器挂接在一起
  42. m_pm.Init(m_hWnd);
  43. m_pm.AddPreMessageFilter(this);
  44. CDialogBuilder builder;
  45. CControlUI* pRoot = builder.Create(_T("messagebox_dlg.xml"), (UINT)0, NULL, &m_pm);
  46. ASSERT(pRoot && "Failed to parse XML");
  47. // 把这些控件绘制到本窗口上
  48. m_pm.AttachDialog(pRoot);
  49. // 把自己加入到CPaintManagerUI的m_aNotifiers数组中,用于处理Notify函数
  50. m_pm.AddNotifier(this);
  51. Init();
  52. return 0;
  53. }
  54. LRESULT OnNcActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  55. {
  56. if(::IsIconic(*this))
  57. {
  58. bHandled = FALSE;
  59. }
  60. return (wParam == 0) ? TRUE : FALSE;
  61. }
  62. LRESULT OnNcCalcSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  63. {
  64. return 0;
  65. }
  66. LRESULT OnNcPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  67. {
  68. return 0;
  69. }
  70. LRESULT OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  71. LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  72. LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
  73. LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled);
  74. public:
  75. CPaintManagerUI m_pm;
  76. };