CWaimaiOrderFailReasonWnd.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. #pragma once
  2. #include "../pch/pch.h"
  3. #include "CMainWnd.h"
  4. class CWaimaiOrderFailReasonWnd : public CWindowWnd, public INotifyUI, public IMessageFilterUI
  5. {
  6. public:
  7. LPCTSTR GetWindowClassName() const
  8. {
  9. return _T("UIWaimaiOrderFailFrame");
  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. std::string getReason()
  25. {
  26. return m_reason;
  27. }
  28. void Notify(TNotifyUI& msg)
  29. {
  30. if(msg.sType == _T("click"))
  31. {
  32. DuiLib::CDuiString senderName = msg.pSender->GetName();
  33. if(senderName == _T("waimai_order_fail_dlg_closebtn"))
  34. {
  35. Close(IDCANCEL);
  36. return;
  37. }
  38. else if(senderName == _T("waimai_order_fail_dlg_save"))
  39. {
  40. //开始保存厨房打印机的数据
  41. CEditUI* pReason = static_cast<CEditUI*>(m_pm.FindControl(_T("waimai_order_fail_dlg_reason")));
  42. wstring wsReason = pReason->GetText();
  43. m_reason = CLewaimaiString::UnicodeToUTF8(wsReason);
  44. Close(IDOK);
  45. return;
  46. }
  47. }
  48. }
  49. LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  50. {
  51. LONG styleValue = ::GetWindowLong(*this, GWL_STYLE);
  52. styleValue &= ~WS_CAPTION;
  53. ::SetWindowLong(*this, GWL_STYLE, styleValue | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
  54. // 把自己的窗口句柄与窗口绘制管理器挂接在一起
  55. m_pm.Init(m_hWnd);
  56. m_pm.AddPreMessageFilter(this);
  57. CDialogBuilder builder;
  58. CControlUI* pRoot = builder.Create(_T("waimai_order_fail_reason_dlg.xml"), (UINT)0, NULL, &m_pm);
  59. ASSERT(pRoot && "Failed to parse XML");
  60. // 把这些控件绘制到本窗口上
  61. m_pm.AttachDialog(pRoot);
  62. // 把自己加入到CPaintManagerUI的m_aNotifiers数组中,用于处理Notify函数
  63. m_pm.AddNotifier(this);
  64. Init();
  65. return 0;
  66. }
  67. LRESULT OnNcActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  68. {
  69. if(::IsIconic(*this))
  70. {
  71. bHandled = FALSE;
  72. }
  73. return (wParam == 0) ? TRUE : FALSE;
  74. }
  75. LRESULT OnNcCalcSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  76. {
  77. return 0;
  78. }
  79. LRESULT OnNcPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  80. {
  81. return 0;
  82. }
  83. LRESULT OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  84. LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  85. LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
  86. LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled);
  87. public:
  88. CPaintManagerUI m_pm;
  89. std::string m_reason;
  90. };