view src/win32/Commands.cpp @ 4:5f6f2134e8ce

apu appears to not be used
author Robert McIntyre <rlm@mit.edu>
date Sat, 03 Mar 2012 10:35:58 -0600
parents f9f4f1b99eed
children
line wrap: on
line source
1 #include "stdafx.h"
2 #include <afxres.h>
3 #include "resource.h"
4 #include "AcceleratorManager.h"
6 #ifndef CMapStringToWord
7 typedef CMap< CString, LPCSTR, WORD, WORD & > CMapStringToWord;
8 #endif
10 static CMapStringToWord winAccelStrings;
11 static bool initialized = false;
13 struct
14 {
15 const char *command;
16 WORD id;
17 } winAccelCommands[] = {
18 { "Minimize", ID_SYSTEM_MINIMIZE },
19 { "Maximize", ID_SYSTEM_MAXIMIZE },
20 };
22 void winAccelAddCommandsFromTable(CAcceleratorManager &mgr)
23 {
24 int count = sizeof(winAccelCommands)/sizeof(winAccelCommands[0]);
26 for (int i = 0; i < count; i++)
27 {
28 if (!mgr.AddCommandAccel(winAccelCommands[i].id, winAccelCommands[i].command, false))
29 mgr.CreateEntry(winAccelCommands[i].id, winAccelCommands[i].command);
30 }
31 }
33 // recursive calls
34 void winAccelAddCommandsFromMenu(CAcceleratorManager &mgr, CMenu *pMenu, const CString &parentStr)
35 {
36 UINT nIndexMax = pMenu->GetMenuItemCount();
37 for (UINT nIndex = 0; nIndex < nIndexMax; ++nIndex)
38 {
39 UINT nID = pMenu->GetMenuItemID(nIndex);
40 if (nID == 0)
41 continue; // menu separator or invalid cmd - ignore it
43 if (nID == (UINT)-1)
44 {
45 // possibly a submenu
46 CMenu *pSubMenu = pMenu->GetSubMenu(nIndex);
47 if (pSubMenu != NULL)
48 {
49 CString tempStr;
50 pMenu->GetMenuString(nIndex, tempStr, MF_BYPOSITION);
51 tempStr.Remove('&');
52 winAccelAddCommandsFromMenu(mgr, pSubMenu, parentStr + '\\' + tempStr);
53 }
54 }
55 else
56 {
57 // normal menu item
58 // generate the strings
59 CString command;
60 pMenu->GetMenuString(nIndex, command, MF_BYPOSITION);
61 int nPos = command.ReverseFind('\t');
62 if (nPos != -1)
63 {
64 command.Delete(nPos, command.GetLength() - nPos);
65 }
66 command.Remove('&');
67 command = parentStr + '\\' + command;
68 if (!mgr.AddCommandAccel(nID, command, false))
69 {
70 mgr.CreateEntry(nID, command);
71 }
72 }
73 }
74 }