PressKeyEditControl.cpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* Copyright (c) 2002-2012 Croteam Ltd.
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of version 2 of the GNU General Public License as published by
  4. the Free Software Foundation
  5. This program is distributed in the hope that it will be useful,
  6. but WITHOUT ANY WARRANTY; without even the implied warranty of
  7. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  8. GNU General Public License for more details.
  9. You should have received a copy of the GNU General Public License along
  10. with this program; if not, write to the Free Software Foundation, Inc.,
  11. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
  12. // PressKeyEditControl.cpp : implementation file
  13. //
  14. #include "stdafx.h"
  15. #ifdef _DEBUG
  16. #undef new
  17. #define new DEBUG_NEW
  18. #undef THIS_FILE
  19. static char THIS_FILE[] = __FILE__;
  20. #endif
  21. /////////////////////////////////////////////////////////////////////////////
  22. // CPressKeyEditControl
  23. CPressKeyEditControl::CPressKeyEditControl()
  24. {
  25. }
  26. CPressKeyEditControl::~CPressKeyEditControl()
  27. {
  28. }
  29. BEGIN_MESSAGE_MAP(CPressKeyEditControl, CEdit)
  30. //{{AFX_MSG_MAP(CPressKeyEditControl)
  31. //}}AFX_MSG_MAP
  32. END_MESSAGE_MAP()
  33. /////////////////////////////////////////////////////////////////////////////
  34. // CPressKeyEditControl message handlers
  35. BOOL CPressKeyEditControl::PreTranslateMessage(MSG* pMsg)
  36. {
  37. // if direct input is curently on
  38. if( _pInput->IsInputEnabled())
  39. {
  40. // and if we caught alt key message
  41. if( pMsg->message==WM_SYSKEYDOWN)
  42. {
  43. // get key data
  44. int lKeyData = pMsg->lParam;
  45. // test if it is ghost Alt-F4 situation
  46. if( lKeyData & (1L<<29))
  47. {
  48. // don't continue translating the message
  49. return TRUE;
  50. }
  51. }
  52. // test if game is paused, stop messages otherwise let messages trough
  53. if (pMsg->message==WM_KEYDOWN)
  54. {
  55. // direct input is enabled, so don't translate messages
  56. return TRUE;
  57. }
  58. }
  59. return CEdit::PreTranslateMessage(pMsg);
  60. }