CChufangSettingWnd.cpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #include "../pch/pch.h"
  2. #include "CChufangSettingWnd.h"
  3. LRESULT CChufangSettingWnd::OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  4. {
  5. POINT pt;
  6. pt.x = GET_X_LPARAM(lParam);
  7. pt.y = GET_Y_LPARAM(lParam);
  8. ::ScreenToClient(*this, &pt);
  9. RECT rcClient;
  10. ::GetClientRect(*this, &rcClient);
  11. RECT rcCaption = m_pm.GetCaptionRect();
  12. if (pt.x >= rcClient.left + rcCaption.left && pt.x < rcClient.right - rcCaption.right \
  13. && pt.y >= rcCaption.top && pt.y < rcCaption.bottom)
  14. {
  15. CControlUI* pControl = static_cast<CControlUI*>(m_pm.FindControl(pt));
  16. if (pControl && _tcscmp(pControl->GetClass(), DUI_CTR_BUTTON) != 0)
  17. {
  18. return HTCAPTION;
  19. }
  20. }
  21. return HTCLIENT;
  22. }
  23. LRESULT CChufangSettingWnd::OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  24. {
  25. SIZE szRoundCorner = m_pm.GetRoundCorner();
  26. if (!::IsIconic(*this) && (szRoundCorner.cx != 0 || szRoundCorner.cy != 0))
  27. {
  28. CDuiRect rcWnd;
  29. ::GetWindowRect(*this, &rcWnd);
  30. rcWnd.Offset(-rcWnd.left, -rcWnd.top);
  31. rcWnd.right++;
  32. rcWnd.bottom++;
  33. HRGN hRgn = ::CreateRoundRectRgn(rcWnd.left, rcWnd.top, rcWnd.right, rcWnd.bottom, szRoundCorner.cx, szRoundCorner.cy);
  34. ::SetWindowRgn(*this, hRgn, TRUE);
  35. ::DeleteObject(hRgn);
  36. }
  37. bHandled = FALSE;
  38. return 0;
  39. }
  40. LRESULT CChufangSettingWnd::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
  41. {
  42. LRESULT lRes = 0;
  43. BOOL bHandled = TRUE;
  44. switch (uMsg)
  45. {
  46. case WM_CREATE:
  47. lRes = OnCreate(uMsg, wParam, lParam, bHandled);
  48. break;
  49. case WM_NCACTIVATE:
  50. lRes = OnNcActivate(uMsg, wParam, lParam, bHandled);
  51. break;
  52. case WM_NCCALCSIZE:
  53. lRes = OnNcCalcSize(uMsg, wParam, lParam, bHandled);
  54. break;
  55. case WM_NCPAINT:
  56. lRes = OnNcPaint(uMsg, wParam, lParam, bHandled);
  57. break;
  58. case WM_NCHITTEST:
  59. lRes = OnNcHitTest(uMsg, wParam, lParam, bHandled);
  60. break;
  61. case WM_SIZE:
  62. lRes = OnSize(uMsg, wParam, lParam, bHandled);
  63. break;
  64. default:
  65. bHandled = FALSE;
  66. }
  67. if (bHandled)
  68. {
  69. return lRes;
  70. }
  71. if (m_pm.MessageHandler(uMsg, wParam, lParam, lRes))
  72. {
  73. return lRes;
  74. }
  75. return CWindowWnd::HandleMessage(uMsg, wParam, lParam);
  76. }
  77. LRESULT CChufangSettingWnd::MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled)
  78. {
  79. if (uMsg == WM_KEYDOWN)
  80. {
  81. if (wParam == VK_RETURN)
  82. {
  83. return true;
  84. }
  85. else if (wParam == VK_ESCAPE)
  86. {
  87. return true;
  88. }
  89. }
  90. return false;
  91. }