////////////////////////////////////////////////////////////////////// // In/Out to the registry ////////////////////////////////////////////////////////////////////// // // bool CAcceleratorManager::Load(HKEY hRegKey, LPCTSTR szRegKey) { ASSERT(szRegKey != NULL); m_hRegKey = hRegKey; m_szRegKey = szRegKey; DWORD data[2048/sizeof(DWORD)]; DWORD len = sizeof(data); if(regQueryBinaryValue("keyboard", (char *)data, len)) { int count = len/sizeof(DWORD); CCmdAccelOb* pCmdAccel; CAccelsOb* pAccel; DWORD dwIDAccelData, dwAccelData; BOOL bExistID; int iIndex = 0; if(count) { WORD wKey; POSITION pos = m_mapAccelTable.GetStartPosition(); while(pos != NULL) { m_mapAccelTable.GetNextAssoc(pos, wKey, pCmdAccel); pCmdAccel->DeleteUserAccels(); } while(iIndex < count) { dwIDAccelData = data[iIndex++]; WORD wIDCommand = LOWORD(dwIDAccelData); bExistID = m_mapAccelTable.Lookup(wIDCommand, pCmdAccel); if (bExistID) { pCmdAccel->DeleteUserAccels(); } for (int j = 0; j < HIWORD(dwIDAccelData) && iIndex < count; j++) { dwAccelData = data[iIndex++]; if (bExistID) { pAccel = new CAccelsOb; ASSERT(pAccel != NULL); pAccel->SetData(dwAccelData); pCmdAccel->Add(pAccel); } } } } UpdateWndTable(); return true; } return false; }
////////////////////////////////////////////////////////////////////// // In/Out to the registry ////////////////////////////////////////////////////////////////////// // // bool CAcceleratorManager::Load(HKEY hRegKey, LPCTSTR szRegKey) { ASSERT(szRegKey != NULL); HKEY hKey; m_hRegKey = hRegKey; m_szRegKey = szRegKey; LONG res = RegOpenKeyEx(hRegKey, szRegKey, 0L, KEY_ALL_ACCESS, &hKey); if(res == ERROR_SUCCESS) { DWORD data[2048/sizeof(DWORD)]; DWORD dwType; DWORD len = sizeof(data); res = RegQueryValueEx(hKey, "keyboard", NULL, &dwType, (LPBYTE)data, &len); RegCloseKey(hKey); if(res == ERROR_SUCCESS) { int count = len/sizeof(DWORD); CCmdAccelOb* pCmdAccel; CAccelsOb* pAccel; DWORD dwIDAccelData, dwAccelData; int iIndex = 0; if(count) { while(iIndex < count) { dwIDAccelData = data[iIndex++]; WORD wIDCommand = LOWORD(dwIDAccelData); CMapWordToCCmdAccelOb::iterator it = m_mapAccelTable.find(wIDCommand); bool bExistID = (it != m_mapAccelTable.end()); if (bExistID) { pCmdAccel = it->second; pCmdAccel->DeleteUserAccels(); } for (int j = 0; j < HIWORD(dwIDAccelData) && iIndex < count; j++) { dwAccelData = data[iIndex++]; if (bExistID) { pAccel = new CAccelsOb; ASSERT(pAccel != NULL); pAccel->SetData(dwAccelData); pCmdAccel->Add(pAccel); } } } } UpdateWndTable(); return true; } return false; } return true; }
bool CAcceleratorManager::Default() { CCmdAccelOb* pCmdAccel; CCmdAccelOb* pSavedCmdAccel; CAccelsOb* pAccel; CAccelsOb* pSavedAccel; WORD wKey; CMapWordToCCmdAccelOb::iterator it = m_mapAccelTable.begin(); while(it != m_mapAccelTable.end()) { wKey = it->first; pCmdAccel = it->second; pCmdAccel->DeleteUserAccels(); it++; } // @ Add the saved Accelerators it = m_mapAccelTableSaved.begin(); while (it != m_mapAccelTableSaved.end()) { wKey = it->first; pSavedCmdAccel = it->second; it++; pCmdAccel = m_mapAccelTable.find(wKey)->second; // @ Removed by kukac pCmdAccel->DeleteUserAccels(); std::list<CAccelsOb*>::iterator it = pSavedCmdAccel->m_Accels.begin(); while (it != pSavedCmdAccel->m_Accels.end()) { pSavedAccel = *it; it++; pAccel = new CAccelsOb(pSavedAccel); ASSERT(pAccel != NULL); pCmdAccel->m_Accels.push_back(pAccel); } } return true; }