CWaimaiOrderFailReasonWnd.h 2.5 KB

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