DIKeyState.h
上传用户:wymy58
上传日期:2007-01-07
资源大小:2086k
文件大小:1k
源码类别:

DirextX编程

开发平台:

Visual C++

  1. // Copyright (C) 1998-1999 DXGuide.  All Rights Reserved.
  2. // File: DIKeyState.h
  3. #ifndef _DIKEYSTATE__H
  4. #define _DIKEYSTATE__H
  5. #if _MSC_VER >= 1000
  6. #pragma once
  7. #endif // _MSC_VER >= 1000
  8. class CDIKeyboard;
  9. class CDIKeyState
  10. {
  11. friend class CDXGUIManager;
  12. public:
  13. enum KB_MASK
  14. {
  15. KB_RSHIFTMASK = 0x0001,
  16. KB_LSHIFTMASK = 0x0002,
  17. KB_RCTRLMASK = 0x0004,
  18. KB_LCTRLMASK = 0x0008,
  19. KB_RALTMASK = 0x0010,
  20. KB_LALTMASK = 0x0020,
  21. KB_DBCSMASK = 0x8000,
  22. };
  23. enum KEY_STATE
  24. {
  25. KEY_NONE,
  26. KEY_DOWN,
  27. KEY_UP,
  28. };
  29. protected:
  30. CDIKeyState(void);
  31. ~CDIKeyState();
  32. protected:
  33. bool Create(CDIKeyboard*  pKeyboard, DWORD  dwBufferSize = 16);
  34. public:
  35. void Update(void);
  36. CDIKeyState::KEY_STATE GetKeyState(void);
  37. DWORD GetKeyCode(void) const;
  38. TCHAR GetChar(void) const;
  39. DWORD GetKeyTimeStamp(void) const;
  40. public:
  41. bool IsCtrlPressed(void) const;
  42. bool IsAltPressed(void) const;
  43. bool IsShiftPressed(void) const;
  44. bool IsDBCSKeyCode(void) const;
  45. void ClearDBCSFlag(void);
  46. void DisableCtrl(void);
  47. void DisableAlt(void);
  48. void DisableShift(void);
  49. void EnableCtrl(void);
  50. void EnableAlt(void);
  51. void EnableShift(void);
  52. protected:
  53. KEY_STATE m_KeyState;
  54. DWORD m_dwKeyCode;
  55. DWORD m_dwKeyTimeStamp;
  56. DWORD m_dwControlKeyState;
  57. DWORD m_dwDisableControlKeyFlag;
  58. public:
  59. void PostKeyInfo(DWORD  dwKeyCode,
  60. DWORD  dwControlKeyState);
  61. protected:
  62. CDIKeyboard* m_pKeyboard;
  63. };
  64. #include "DIKeyState.inl"
  65. #endif // _DIKEYSTATE__H