-
Notifications
You must be signed in to change notification settings - Fork 1
/
HotKeyList.h
93 lines (73 loc) · 2.05 KB
/
HotKeyList.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// Copyleft 2004 Chris Korda
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 of the License, or any later version.
/*
chris korda
revision history:
rev date comments
00 04feb05 initial version
manage a list of hot keys
*/
#ifndef HOTKEYLIST_INCLUDED
#define HOTKEYLIST_INCLUDED
#include <afxtempl.h>
class CAccelTable;
class CHotKeyList {
public:
// Construction
CHotKeyList();
// Initialization
bool LoadAccelRes(int ResID);
void LoadAccelHandle(HACCEL Accel);
void LoadAccelTable(const CAccelTable& Table);
// Attributes
int GetCount() const;
const ACCEL& GetAccel(int Idx) const;
DWORD GetKey(int Idx) const;
WORD GetCmd(int Idx) const;
void SetKey(int Idx, DWORD Key, WORD Cmd);
void GetKeyName(int Idx, CString& KeyName) const;
void GetCmdName(int Idx, CString& CmdName) const;
void GetCmdHelp(int Idx, CString& CmdHelp) const;
// Operations
void CreateAccelTable(CAccelTable& Table) const;
void RemoveAll();
int AddKey(DWORD Key, WORD Cmd);
void InsertKey(int Idx, DWORD Key, WORD Cmd);
void DeleteKey(int Idx);
int FindKey(DWORD Key) const;
// Conversions
static DWORD AccelToKey(const ACCEL& Accel, WORD& Cmd);
static void KeyToAccel(DWORD Key, WORD Cmd, ACCEL& Accel);
static void KeyToName(DWORD Key, CString& KeyName);
static void CmdToName(WORD Cmd, CString& CmdName);
protected:
// Member data
CArray<ACCEL, ACCEL&> m_Accel;
// Helpers
CString GetKeyNameText(LONG lParam) const;
NOCOPIES(CHotKeyList);
};
inline int CHotKeyList::GetCount() const
{
return(m_Accel.GetSize());
}
inline const ACCEL& CHotKeyList::GetAccel(int Idx) const
{
return(m_Accel.GetData()[Idx]);
}
inline DWORD CHotKeyList::GetKey(int Idx) const
{
WORD Cmd;
return(AccelToKey(m_Accel[Idx], Cmd));
}
inline WORD CHotKeyList::GetCmd(int Idx) const
{
return(m_Accel[Idx].cmd);
}
inline void CHotKeyList::SetKey(int Idx, DWORD Key, WORD Cmd)
{
KeyToAccel(Key, Cmd, m_Accel[Idx]);
}
#endif