PointerSelectObjectDlg.cpp 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /*************************************************************************************************\
  2. PointerSelectObjectDlg.cpp : Implementation of the PointerSelectObjectDlg component.
  3. //---------------------------------------------------------------------------//
  4. // Copyright (C) Microsoft Corporation. All rights reserved. //
  5. //===========================================================================//
  6. \*************************************************************************************************/
  7. #include "resource.h"
  8. #include <stdlib.h>
  9. #include <assert.h>
  10. #include "EString.h"
  11. #include "PointerSelectObjectDlg.h"
  12. #include "Objective.h"
  13. #include "EditorInterface.h"
  14. #include "MFCPlatform.hpp"
  15. static const int WM_DOTICK = WM_USER + 1;
  16. //-------------------------------------------------------------------------------------------------
  17. PointerSelectObjectDlg::PointerSelectObjectDlg():CDialog(IDD_POINTER_SELECT_OBJECT)
  18. {
  19. m_pButton = 0;
  20. m_bTimerIsReset = true;
  21. }
  22. PointerSelectObjectDlg::PointerSelectObjectDlg(int x, int y):CDialog(IDD_POINTER_SELECT_OBJECT)
  23. {
  24. m_pButton = 0;
  25. m_bTimerIsReset = true;
  26. }
  27. BOOL PointerSelectObjectDlg::OnInitDialog()
  28. {
  29. //m_pButton = (CButton *)GetDlgItem(IDC_POINTER_SELECT_OBJECT_BUTTON);
  30. //assert( m_pButton );
  31. RECT rc;
  32. EditorInterface::instance()->GetClientRect(&rc);
  33. EditorInterface::instance()->ClientToScreen(&rc);
  34. MoveWindow(&rc);
  35. return 1;
  36. }
  37. UINT PointerSelectObjectDlg::OnNcHitTest( CPoint point )
  38. {
  39. return HTCLIENT;
  40. }
  41. BOOL PointerSelectObjectDlg::OnCommand(WPARAM wParam, LPARAM lParam) // called by child controls to inform of an event
  42. {
  43. // HWND hWndCtrl = (HWND)lParam;
  44. // if (hWndCtrl == m_pButton->m_hWnd)
  45. // {
  46. // EndDialog(0);
  47. // }
  48. return inherited::OnCommand(wParam, lParam);
  49. }
  50. #include "afxpriv.h" // just for definition of WM_KICKIDLE
  51. BOOL PointerSelectObjectDlg::OnWndMsg( UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult )
  52. {
  53. switch (message)
  54. {
  55. case WM_LBUTTONDOWN:
  56. {
  57. }
  58. break;
  59. case WM_RBUTTONDOWN:
  60. {
  61. EndDialog(0);
  62. return TRUE;
  63. }
  64. break;
  65. case WM_ACTIVATE:
  66. {
  67. }
  68. break;
  69. case WM_CAPTURECHANGED:
  70. {
  71. }
  72. break;
  73. case WM_NCHITTEST:
  74. {
  75. }
  76. break;
  77. case WM_PAINT:
  78. {
  79. PAINTSTRUCT ps;
  80. BeginPaint(&ps);
  81. EndPaint(&ps);
  82. //m_pButton->Invalidate(FALSE);
  83. return TRUE;
  84. }
  85. break;
  86. case WM_TIMER:
  87. {
  88. ::KillTimer(GetSafeHwnd(), wParam);
  89. EditorInterface::instance()->SafeRunGameOSLogic();
  90. m_bTimerIsReset = true;
  91. //m_pButton->Invalidate(FALSE);
  92. return TRUE;
  93. }
  94. break;
  95. case WM_KEYDOWN:
  96. {
  97. //int i = 17;
  98. }
  99. break;
  100. }
  101. BOOL ret = CDialog::OnWndMsg( message, wParam, lParam, pResult );
  102. if (((WM_MOUSEFIRST <= message) && (WM_MOUSELAST >= message))) {
  103. POINT pt;
  104. pt.x = LOWORD(lParam);
  105. pt.y = HIWORD(lParam);
  106. ClientToScreen(&pt);
  107. EditorInterface::instance()->ScreenToClient(&pt);
  108. lParam = MAKELPARAM(pt.x, pt.y);
  109. EditorInterface::instance()->SendMessage(message, wParam, lParam);
  110. } else if ((WM_KEYDOWN == message) || (WM_KEYUP == message)) {
  111. switch ((int)wParam) {
  112. case VK_RETURN:
  113. case VK_SPACE:
  114. case VK_PRIOR:
  115. case VK_NEXT:
  116. case VK_END:
  117. case VK_HOME:
  118. case VK_LEFT:
  119. case VK_UP:
  120. case VK_RIGHT:
  121. case VK_DOWN:
  122. case VK_ADD:
  123. case VK_SUBTRACT:
  124. EditorInterface::instance()->SendMessage(message, wParam, lParam);
  125. break;
  126. }
  127. }
  128. {
  129. static int depth = 0;
  130. if (0 == depth) {
  131. MSG msg;
  132. /* calling PeekMessage() from within OnWndMsg() allows it to become reentrant */
  133. depth += 1;
  134. BOOL result = PeekMessage(&msg, GetSafeHwnd(), 0, 0, PM_NOREMOVE);
  135. depth -= 1;
  136. if ((0 == result) && (m_bTimerIsReset)) {
  137. unsigned int ui = ::SetTimer(GetSafeHwnd(), 1/*arbitrary non-zero ID*/, 2/*milliseconds*/, NULL);
  138. assert(ui);
  139. m_bTimerIsReset = false;
  140. }
  141. }
  142. }
  143. return ret;
  144. }
  145. //-------------------------------------------------------------------------------------------------
  146. PointerSelectObjectDlg::~PointerSelectObjectDlg()
  147. {
  148. }
  149. //*************************************************************************************************
  150. // end of file ( PointerSelectObjectDlg.cpp )