// MouseManager.cpp // // (c)1998-2025 Codejock Software, All Rights Reserved. // // THIS SOURCE FILE IS THE PROPERTY OF CODEJOCK SOFTWARE AND IS NOT TO BE // RE-DISTRIBUTED BY ANY MEANS WHATSOEVER WITHOUT THE EXPRESSED WRITTEN // CONSENT OF CODEJOCK SOFTWARE. // // THIS SOURCE CODE CAN ONLY BE USED UNDER THE TERMS AND CONDITIONS OUTLINED // IN THE XTREME TOOLKIT PRO LICENSE AGREEMENT. CODEJOCK SOFTWARE GRANTS TO // YOU (ONE SOFTWARE DEVELOPER) THE LIMITED RIGHT TO USE THIS SOFTWARE ON A // SINGLE COMPUTER. // // CONTACT INFORMATION: // support@codejock.com // http://www.codejock.com // ///////////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "MouseManager.h" #ifdef _DEBUG # undef THIS_FILE static char THIS_FILE[] = __FILE__; # define new DEBUG_NEW #endif CMap CMouseManager::m_mapStrings; CArray CMouseManager::m_arrMouse; BOOL CMouseManager::Load() { BOOL bSucess = FALSE; BYTE* pData = NULL; UINT uDataSize; if (!AfxGetApp()->GetProfileBinary(_T("MouseManager"), _T("State"), (LPBYTE*)&pData, &uDataSize)) { _ASSERTE(pData == NULL); return FALSE; } _ASSERTE(pData != NULL); try { CMemFile file(pData, uDataSize); CArchive ar(&file, CArchive::load); m_arrMouse.Serialize(ar); bSucess = TRUE; } catch (CMemoryException* pEx) { pEx->Delete(); TRACE(_T("Memory exception in CRegistry::Read ()!\n")); } catch (CArchiveException* pEx) { pEx->Delete(); TRACE(_T("CArchiveException exception in CRegistry::Read ()!\n")); } delete pData; return bSucess; } void CMouseManager::Save() { BOOL bRes = FALSE; try { CMemFile file; { CArchive ar(&file, CArchive::store); m_arrMouse.Serialize(ar); ar.Flush(); } DWORD dwDataSize = (DWORD)file.GetLength(); LPBYTE lpbData = file.Detach(); if (lpbData == NULL) { return; } bRes = AfxGetApp()->WriteProfileBinary(_T("MouseManager"), _T("State"), lpbData, (UINT)dwDataSize); free(lpbData); } catch (CMemoryException* pEx) { pEx->Delete(); TRACE(_T("Memory exception in CRegistry::Write ()!\n")); } } int CMouseManager::FindMouseCommand(int nArea, DWORD dwMouse) { for (int i = 0; i < m_arrMouse.GetSize(); i++) { MOUSECLICKS& mc = m_arrMouse[i]; if (mc.nArea == nArea && mc.dwMouse == dwMouse) { int nVirt = (GetKeyState(VK_CONTROL) < 0 ? FCONTROL : 0) | (GetKeyState(VK_SHIFT) < 0 ? FSHIFT : 0) | (GetKeyState(VK_MENU) < 0 ? FALT : 0); if (nVirt == mc.accel.fVirt) return mc.accel.cmd; } } return -1; } CString CMouseManager::GetMouseString(DWORD dwMouse) { CString strMouse; if (!m_mapStrings.Lookup(dwMouse, strMouse)) { VERIFY(strMouse.LoadString(dwMouse)); m_mapStrings.SetAt(dwMouse, strMouse); } return strMouse; } void CMouseManager::AddCommand(DWORD dwMouse, ACCEL accel, int nArea) { MOUSECLICKS mc = { dwMouse, nArea }; mc.accel = accel; m_arrMouse.Add(mc); }