Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
1.8 KiB

  1. // AccelContainer.h: interface for the CAccelContainer class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #if !defined(AFX_ACCELCONTAINER_H__DEBE6100_DEDC_41E0_995A_67D2922897D0__INCLUDED_)
  5. #define AFX_ACCELCONTAINER_H__DEBE6100_DEDC_41E0_995A_67D2922897D0__INCLUDED_
  6. #if _MSC_VER > 1000
  7. #pragma once
  8. #endif // _MSC_VER > 1000
  9. ///////////////////////////////// STL
  10. #pragma warning(disable:4786)
  11. #include <string>
  12. #include <xstring>
  13. #include <map>
  14. #include <algorithm>
  15. #include <vector>
  16. #include <set>
  17. using namespace std;
  18. /////////////////////////////////////
  19. class CAccelContainer
  20. {
  21. public:
  22. CAccelContainer() {}
  23. virtual ~CAccelContainer() {}
  24. typedef vector<ACCEL > ACCELVECTOR;
  25. ACCELVECTOR m_Accel; // accelerators
  26. CAccelContainer& operator=(LPCTSTR lpszStr) {
  27. SetAccel(lpszStr);
  28. return *this;
  29. }
  30. void SetAccel(LPCTSTR lpszStr, WORD wCmd = 0) {
  31. ParseAccelString(lpszStr, wCmd);
  32. }
  33. void ClearAccel() {
  34. m_Accel.erase(m_Accel.begin(), m_Accel.end());
  35. }
  36. VOID ParseAccelString(LPCTSTR lpszStr, WORD wCmd);
  37. BOOL IsAccelKey(LPMSG pMsg, WORD* pCmd = NULL);
  38. int GetCount() {
  39. return m_Accel.size();
  40. }
  41. const ACCEL& GetAccel(int nPos) {
  42. return m_Accel[nPos];
  43. }
  44. wstring GetKeyFromAccel(const ACCEL& accel);
  45. wstring GetAccelString(WORD wCmd = 0) {
  46. ACCELVECTOR::iterator iter;
  47. wstring strAccel;
  48. for (iter = m_Accel.begin(); iter != m_Accel.end(); ++iter) {
  49. const ACCEL& accel = *iter;
  50. if (accel.cmd == wCmd) {
  51. strAccel += GetKeyFromAccel(accel);
  52. }
  53. }
  54. return strAccel;
  55. }
  56. };
  57. #endif // !defined(AFX_ACCELCONTAINER_H__DEBE6100_DEDC_41E0_995A_67D2922897D0__INCLUDED_)