BOOL CConfigShortcuts::OnApply() { CAccelerator *pAccel = theApp.GetAccelerator(); std::unordered_map<int, int> m; // // // check for conflicts for (int i = 0; i < CAccelerator::ACCEL_COUNT; ++i) { int KeyVal = (m_iKeys[i] & 0xFF) | (m_iMods[i] << 8); if (!KeyVal) continue; auto it = m.find(KeyVal); if (it == m.end()) m[KeyVal] = i; else { AfxMessageBox(FormattedW(L"These two commands are assigned to the same shortcut (%s):\n- %s\n- %s", (LPCWSTR)AssembleKeyString(m_iMods[i], m_iKeys[i]), CAccelerator::DEFAULT_TABLE[it->second].name, CAccelerator::DEFAULT_TABLE[i].name), MB_ICONERROR); return FALSE; } } // Store keys for (int i = 0; i < CAccelerator::ACCEL_COUNT; ++i) pAccel->StoreShortcut(i, m_iKeys[i], m_iMods[i]); pAccel->Setup(); theApp.UpdateMenuShortcuts(); // // // return CPropertyPage::OnApply(); }
void CConfigShortcuts::OnNMClickShortcuts(NMHDR *pNMHDR, LRESULT *pResult) { CListCtrl *pListView = static_cast<CListCtrl*>(GetDlgItem(IDC_SHORTCUTS)); m_iSelectedItem = pListView->GetSelectionMark(); CStringW KeyString = AssembleKeyString(m_iMods[m_iSelectedItem], m_iKeys[m_iSelectedItem]); SetDlgItemTextW(IDC_KEY, KeyString); *pResult = 0; }
void CConfigShortcuts::SetupKey(int Key) { int Mod = (m_bShift ? MOD_SHIFT : 0) | (m_bControl ? MOD_CONTROL : 0) | (m_bAlt ? MOD_ALT : 0); StoreKey(m_iSelectedItem, Key, Mod); // Display key CStringW KeyStr = AssembleKeyString(Mod, Key); SetDlgItemTextW(IDC_KEY, KeyStr); SetModified(); }
void CConfigShortcuts::OnBnClickedDefault() { CAccelerator *pAccel = theApp.GetAccelerator(); int Key = pAccel->GetDefaultKey(m_iSelectedItem); int Mod = pAccel->GetDefaultMod(m_iSelectedItem); StoreKey(m_iSelectedItem, Key, Mod); CStringW KeyString = AssembleKeyString(Mod, Key); SetDlgItemTextW(IDC_KEY, KeyString); SetModified(); }
void CConfigShortcuts::OnBnClickedDefault() { CListCtrl *pListView = (CListCtrl*)GetDlgItem(IDC_SHORTCUTS); CAccelerator *pAccel = theApp.GetAccelerator(); int Key = pAccel->GetDefaultKey(m_iSelectedItem); int Mod = pAccel->GetDefaultMod(m_iSelectedItem); StoreKey(m_iSelectedItem, Key, Mod); CString KeyString = AssembleKeyString(Mod, Key); SetDlgItemText(IDC_KEY, KeyString); SetModified(); }