#include <Imm.h>\r
#include <Shlwapi.h>\r
#include <TlHelp32.h>\r
-#include <msctf.h>\r
+#include <vector>\r
\r
#ifdef _DEBUG\r
#undef THIS_FILE\r
\r
struct CommandTypeName\r
{\r
- int nCommandType;\r
- LPCTSTR szCommandTypeName;\r
+ int nType;\r
+ LPCTSTR szName;\r
};\r
\r
static const CommandTypeName CommandTypes[] = {\r
{0xff, _T("Fn")},\r
};\r
\r
-CData CProfile::m_Data[MAX_APP];\r
+CONFIG CProfile::m_Config;\r
+TCHAR CProfile::m_szAppTitle[MAX_APP][WINDOW_TEXT_LENGTH];\r
TASK_LIST CProfile::m_TaskList[MAX_TASKS];\r
DWORD CProfile::m_dwTasks;\r
\r
return TRUE;\r
}\r
\r
-struct {\r
- int type;\r
- CString cstr;\r
-} WindowTextTypes[] = {\r
- { IDS_WINDOW_TEXT_MATCH, CString(MAKEINTRESOURCE(IDS_WINDOW_TEXT_MATCH)) },\r
- { IDS_WINDOW_TEXT_MATCH_FORWARD, CString(MAKEINTRESOURCE(IDS_WINDOW_TEXT_MATCH_FORWARD)) },\r
- { IDS_WINDOW_TEXT_MATCH_BACKWARD, CString(MAKEINTRESOURCE(IDS_WINDOW_TEXT_MATCH_BACKWARD)) },\r
-};\r
-\r
-inline int WindowTextType(const CString& cstr) {\r
- for (int i = 0; i < _countof(WindowTextTypes); i++)\r
- if (WindowTextTypes[i].cstr == cstr)\r
- return WindowTextTypes[i].type;\r
- return IDS_WINDOW_TEXT_IGNORE;\r
-}\r
-\r
void CProfile::LoadRegistry()\r
{\r
bool bDialog = false;\r
const CString section(MAKEINTRESOURCE(IDS_REG_SECTION_APPLICATION)); \r
- for (int nAppID = 0; nAppID < MAX_APP; nAppID++) {\r
+ for (int nAppID = 0; nAppID < MAX_APP; ++nAppID) {\r
CString entry;\r
entry.Format(IDS_REG_ENTRY_APPLICATION, nAppID);\r
CString appName = AfxGetApp()->GetProfileString(section, entry);\r
appName.LoadString(IDS_DEFAULT);\r
} else if (appName == CString(MAKEINTRESOURCE(IDS_DIALOG)))\r
bDialog = true;\r
- m_Data[nAppID].SetApplicationName(appName);\r
-\r
+ _tcsncpy_s(m_Config.szSpecialApp[nAppID], appName, _TRUNCATE);\r
entry.LoadString(IDS_REG_ENTRY_APPLICATOIN_TITLE);\r
- m_Data[nAppID].SetApplicationTitle(AfxGetApp()->GetProfileString(appName, entry));\r
+ _tcsncpy_s(m_szAppTitle[nAppID], AfxGetApp()->GetProfileString(appName, entry), _TRUNCATE);\r
entry.LoadString(IDS_REG_ENTRY_WINDOW_TEXT);\r
- m_Data[nAppID].SetWindowText(AfxGetApp()->GetProfileString(appName, entry, _T("*")));\r
- entry.LoadString(IDS_REG_ENTRY_WINDOW_TEXT_TYPE);\r
- m_Data[nAppID].SetWindowTextType(WindowTextType(AfxGetApp()->GetProfileString(appName, entry)));\r
-\r
- CString regApp(MAKEINTRESOURCE(IDS_REGSUBKEY_DATA));\r
- regApp += _T("\\") + appName;\r
- for (int nCommandID = 1; nCommandID < MAX_COMMAND; nCommandID++) {\r
- entry = CCommands::GetCommandName(nCommandID);\r
+ _tcsncpy_s(m_Config.szWindowText[nAppID], AfxGetApp()->GetProfileString(appName, entry, _T("*")), _TRUNCATE);\r
+\r
+ const CString regApp = CString(MAKEINTRESOURCE(IDS_REGSUBKEY_DATA)) + _T("\\") + appName;\r
+ for (int nComID = 1; nComID < MAX_COMMAND; ++nComID) {\r
+ entry = CCommands::GetCommandName(nComID);\r
HKEY hKey;\r
- const CString& regKey = regApp + _T("\\") + entry;\r
+ const CString regKey = regApp + _T("\\") + entry;\r
if (RegOpenKeyEx(HKEY_CURRENT_USER, regKey, 0, KEY_READ, &hKey) == ERROR_SUCCESS) {\r
TCHAR szKeyBind[128];\r
DWORD dwKeyBind = _countof(szKeyBind);\r
- for (DWORD dwIndex = 0; RegEnumKeyEx(hKey, dwIndex, szKeyBind, &dwKeyBind, NULL, NULL, NULL, NULL) == ERROR_SUCCESS; dwIndex++) {\r
- int nCommandType, nKey;\r
- ReadKeyBind(&nCommandType, &nKey, szKeyBind);\r
- m_Data[nAppID].SetCommandID(nCommandType, nKey, nCommandID);\r
+ for (DWORD dwIndex = 0; RegEnumKeyEx(hKey, dwIndex, szKeyBind, &dwKeyBind, NULL, NULL, NULL, NULL) == ERROR_SUCCESS; ++dwIndex) {\r
+ int nType, nKey;\r
+ ReadKeyBind(&nType, &nKey, szKeyBind);\r
+ m_Config.nCommandID[nAppID][nType][nKey] = nComID;\r
dwKeyBind = _countof(szKeyBind);\r
}\r
RegCloseKey(hKey);\r
} else {\r
// Set the default assignment\r
- for (int i = 0; const int nKey = CCommands::GetDefaultCommandKey(nCommandID, i); i++) {\r
- if (CCommands::GetDefaultControlID(nCommandID, i) == IDC_CO2)\r
+ for (int i = 0; const int nKey = CCommands::GetDefaultCommandKey(nComID, i); ++i) {\r
+ if (CCommands::GetDefaultControlID(nComID, i) == IDC_CO2)\r
continue;\r
- const int nCommandType = CCommands::GetDefaultCommandType(nCommandID, i);\r
- m_Data[nAppID].SetCommandID(nCommandType, nKey, nCommandID);\r
+ const int nType = CCommands::GetDefaultCommandType(nComID, i);\r
+ m_Config.nCommandID[nAppID][nType][nKey] = nComID;\r
}\r
}\r
}\r
- for (int nFunctionID = 0; nFunctionID < CDotXkeymacs::GetFunctionNumber(); nFunctionID++) {\r
+ for (int nFuncID = 0; nFuncID < CDotXkeymacs::GetFunctionNumber(); ++nFuncID) {\r
HKEY hKey;\r
- const CString regKey = regApp + _T("\\") + CDotXkeymacs::GetFunctionSymbol(nFunctionID);\r
+ const CString regKey = regApp + _T("\\") + CDotXkeymacs::GetFunctionSymbol(nFuncID);\r
if (RegOpenKeyEx(HKEY_CURRENT_USER, regKey, 0, KEY_READ, &hKey) == ERROR_SUCCESS) {\r
- CDotXkeymacs::ClearKey(nFunctionID, nAppID);\r
+ CDotXkeymacs::ClearKey(nFuncID, nAppID);\r
TCHAR szKeyBind[128];\r
DWORD dwKeyBind = _countof(szKeyBind);\r
- for (DWORD dwIndex = 0; RegEnumKeyEx(hKey, dwIndex, szKeyBind, &dwKeyBind, NULL, NULL, NULL, NULL) == ERROR_SUCCESS; dwIndex++) {\r
- int nCommandType, nKey;\r
- ReadKeyBind(&nCommandType, &nKey, szKeyBind);\r
- CDotXkeymacs::SetKey(nFunctionID, nAppID, nCommandType, nKey);\r
+ for (DWORD dwIndex = 0; RegEnumKeyEx(hKey, dwIndex, szKeyBind, &dwKeyBind, NULL, NULL, NULL, NULL) == ERROR_SUCCESS; ++dwIndex) {\r
+ int nType, nKey;\r
+ ReadKeyBind(&nType, &nKey, szKeyBind);\r
+ CDotXkeymacs::SetKey(nFuncID, nAppID, nType, nKey);\r
dwKeyBind = _countof(szKeyBind);\r
}\r
RegCloseKey(hKey);\r
}\r
\r
entry.LoadString(IDS_REG_ENTRY_KILL_RING_MAX);\r
- m_Data[nAppID].SetKillRingMax(AfxGetApp()->GetProfileInt(appName, entry, 1));\r
+ m_Config.nKillRingMax[nAppID] = AfxGetApp()->GetProfileInt(appName, entry, 1);\r
entry.LoadString(IDS_REG_ENTRY_USE_DIALOG_SETTING);\r
- m_Data[nAppID].SetUseDialogSetting(AfxGetApp()->GetProfileInt(appName, entry, 1));\r
+ m_Config.bUseDialogSetting[nAppID] = AfxGetApp()->GetProfileInt(appName, entry, 1);\r
entry.LoadString(IDS_REG_ENTRY_DISABLE_XKEYMACS);\r
- m_Data[nAppID].SetSettingStyle(AfxGetApp()->GetProfileInt(appName, entry, 0) ? SETTING_DISABLE : SETTING_SPECIFIC);\r
+ m_Config.nSettingStyle[nAppID] = AfxGetApp()->GetProfileInt(appName, entry, 0) ? SETTING_DISABLE : SETTING_SPECIFIC;\r
entry.LoadString(IDC_REG_ENTRY_IGNORE_META_CTRL);\r
- m_Data[nAppID].SetIgnoreUndefinedMetaCtrl(AfxGetApp()->GetProfileInt(appName, entry, 0));\r
+ m_Config.bIgnoreUndefinedMetaCtrl[nAppID] = AfxGetApp()->GetProfileInt(appName, entry, 0);\r
entry.LoadString(IDC_REG_ENTRY_IGNORE_C_X);\r
- m_Data[nAppID].SetIgnoreUndefinedC_x(AfxGetApp()->GetProfileInt(appName, entry, 0));\r
+ m_Config.bIgnoreUndefinedC_x[nAppID] = AfxGetApp()->GetProfileInt(appName, entry, 0);\r
entry.LoadString(IDC_REG_ENTRY_ENABLE_CUA);\r
- m_Data[nAppID].SetEnableCUA(AfxGetApp()->GetProfileInt(appName, entry, 0));\r
+ m_Config.bEnableCUA[nAppID] = AfxGetApp()->GetProfileInt(appName, entry, 0);\r
entry.LoadString(IDS_REG_ENTRY_326_COMPATIBLE);\r
- m_Data[nAppID].Set326Compatible(AfxGetApp()->GetProfileInt(appName, entry, 0));\r
+ m_Config.b326Compatible[nAppID] = AfxGetApp()->GetProfileInt(appName, entry, 0);\r
}\r
}\r
\r
void CProfile::SaveRegistry()\r
{\r
const CString section(MAKEINTRESOURCE(IDS_REG_SECTION_APPLICATION)); \r
- for (int nAppID = 0; nAppID < MAX_APP; nAppID++) {\r
- const CString& appName = m_Data[nAppID].GetApplicationName();\r
+ for (int nAppID = 0; nAppID < MAX_APP; ++nAppID) {\r
+ const LPCTSTR szAppName = m_Config.szSpecialApp[nAppID];\r
CString entry;\r
entry.Format(IDS_REG_ENTRY_APPLICATION, nAppID);\r
- if (appName.IsEmpty()) {\r
+ if (!szAppName[0]) {\r
if (!AfxGetApp()->GetProfileString(section, entry).IsEmpty())\r
AfxGetApp()->WriteProfileString(section, entry, _T(""));\r
continue;\r
}\r
- AfxGetApp()->WriteProfileString(section, entry, appName);\r
+ AfxGetApp()->WriteProfileString(section, entry, szAppName);\r
\r
entry.LoadString(IDS_REG_ENTRY_APPLICATOIN_TITLE);\r
- CString appTitle = m_Data[nAppID].GetApplicationTitle();\r
+ CString appTitle = m_szAppTitle[nAppID];\r
appTitle.TrimLeft(_T(' '));\r
- AfxGetApp()->WriteProfileString(appName, entry, appTitle);\r
+ AfxGetApp()->WriteProfileString(szAppName, entry, appTitle);\r
entry.LoadString(IDS_REG_ENTRY_WINDOW_TEXT);\r
- AfxGetApp()->WriteProfileString(appName, entry, m_Data[nAppID].GetWindowText());\r
- entry.LoadString(IDS_REG_ENTRY_WINDOW_TEXT_TYPE);\r
- AfxGetApp()->WriteProfileString(appName, entry, CString(MAKEINTRESOURCE(m_Data[nAppID].GetWindowTextType())));\r
+ AfxGetApp()->WriteProfileString(szAppName, entry, m_Config.szWindowText[nAppID]);\r
\r
- CString regApp(MAKEINTRESOURCE(IDS_REGSUBKEY_DATA));\r
- regApp += _T("\\") + appName;\r
+ const CString regApp = CString(MAKEINTRESOURCE(IDS_REGSUBKEY_DATA)) + _T("\\") + szAppName;\r
// Create all commands\r
- for (int nCommandID = 1; nCommandID < MAX_COMMAND; nCommandID++)\r
- SaveCommand(appName, nCommandID);\r
- for (int nCommandType = 0; nCommandType < MAX_COMMAND_TYPE; nCommandType++)\r
- for (int nKey = 0; nKey < MAX_KEY; nKey++)\r
- SaveKeyBind(appName, m_Data[nAppID].GetCommandID(nCommandType, nKey), nCommandType, nKey);\r
- for (int nFunctionID = 0; nFunctionID < CDotXkeymacs::GetFunctionNumber(); nFunctionID++)\r
- for (int nKeyID = 0; nKeyID < CDotXkeymacs::GetKeyNumber(nFunctionID, nAppID); nKeyID++) {\r
- int nCommandType, nKey;\r
- CDotXkeymacs::GetKey(nFunctionID, nAppID, nKeyID, &nCommandType, &nKey);\r
- SaveKeyBind(appName, CDotXkeymacs::GetFunctionSymbol(nFunctionID), nCommandType, nKey);\r
+ for (int nComID = 1; nComID < MAX_COMMAND; ++nComID)\r
+ SaveCommand(szAppName, nComID);\r
+ for (int nType = 0; nType < MAX_COMMAND_TYPE; ++nType)\r
+ for (int nKey = 0; nKey < MAX_KEY; ++nKey)\r
+ SaveKeyBind(szAppName, m_Config.nCommandID[nAppID][nType][nKey], nType, nKey);\r
+ for (int nFuncID = 0; nFuncID < CDotXkeymacs::GetFunctionNumber(); ++nFuncID)\r
+ for (int nKeyID = 0; nKeyID < CDotXkeymacs::GetKeyNumber(nFuncID, nAppID); ++nKeyID) {\r
+ int nType, nKey;\r
+ CDotXkeymacs::GetKey(nFuncID, nAppID, nKeyID, &nType, &nKey);\r
+ SaveKeyBind(szAppName, CDotXkeymacs::GetFunctionSymbol(nFuncID), nType, nKey);\r
}\r
\r
entry.LoadString(IDS_REG_ENTRY_KILL_RING_MAX);\r
- AfxGetApp()->WriteProfileInt(appName, entry, m_Data[nAppID].GetKillRingMax());\r
+ AfxGetApp()->WriteProfileInt(szAppName, entry, m_Config.nKillRingMax[nAppID]);\r
entry.LoadString(IDS_REG_ENTRY_USE_DIALOG_SETTING);\r
- AfxGetApp()->WriteProfileInt(appName, entry, m_Data[nAppID].GetUseDialogSetting());\r
+ AfxGetApp()->WriteProfileInt(szAppName, entry, m_Config.bUseDialogSetting[nAppID]);\r
entry.LoadString(IDS_REG_ENTRY_DISABLE_XKEYMACS);\r
- AfxGetApp()->WriteProfileInt(appName, entry, m_Data[nAppID].GetSettingStyle() == SETTING_DISABLE);\r
+ AfxGetApp()->WriteProfileInt(szAppName, entry, m_Config.nSettingStyle[nAppID] == SETTING_DISABLE);\r
entry.LoadString(IDC_REG_ENTRY_IGNORE_META_CTRL);\r
- AfxGetApp()->WriteProfileInt(appName, entry, m_Data[nAppID].GetIgnoreUndefinedMetaCtrl());\r
+ AfxGetApp()->WriteProfileInt(szAppName, entry, m_Config.bIgnoreUndefinedMetaCtrl[nAppID]);\r
entry.LoadString(IDC_REG_ENTRY_IGNORE_C_X);\r
- AfxGetApp()->WriteProfileInt(appName, entry, m_Data[nAppID].GetIgnoreUndefinedC_x());\r
+ AfxGetApp()->WriteProfileInt(szAppName, entry, m_Config.bIgnoreUndefinedC_x[nAppID]);\r
entry.LoadString(IDC_REG_ENTRY_ENABLE_CUA);\r
- AfxGetApp()->WriteProfileInt(appName, entry, m_Data[nAppID].GetEnableCUA());\r
+ AfxGetApp()->WriteProfileInt(szAppName, entry, m_Config.bEnableCUA[nAppID]);\r
entry.LoadString(IDS_REG_ENTRY_326_COMPATIBLE);\r
- AfxGetApp()->WriteProfileInt(appName, entry, m_Data[nAppID].Get326Compatible());\r
+ AfxGetApp()->WriteProfileInt(szAppName, entry, m_Config.b326Compatible[nAppID]);\r
}\r
}\r
\r
\r
void CProfile::SetDllData()\r
{\r
- CXkeymacsDll::ClearFunctionDefinition();\r
- for (int nFunctionID = 0; nFunctionID < CDotXkeymacs::GetFunctionNumber(); ++nFunctionID) {\r
- CXkeymacsDll::SetFunctionDefinition(nFunctionID, CDotXkeymacs::GetFunctionDefinition(nFunctionID));\r
- }\r
-\r
- for (int nApplicationID = 0; nApplicationID < MAX_APP; ++nApplicationID) {\r
-\r
- CString szApplicationName = m_Data[nApplicationID].GetApplicationName();\r
-\r
- if (szApplicationName.IsEmpty()) {\r
- CXkeymacsDll::Clear(nApplicationID);\r
- continue;\r
- }\r
-\r
- CXkeymacsDll::SetApplicationName(nApplicationID, szApplicationName);\r
- CXkeymacsDll::SetWindowText(nApplicationID, m_Data[nApplicationID].GetWindowText());\r
- CXkeymacsDll::SetCommandID(nApplicationID, CONTROL, 'X', 0);\r
-\r
- for (int nCommandType = 0; nCommandType < MAX_COMMAND_TYPE; ++nCommandType) {\r
- for (int nKey = 0; nKey < MAX_KEY; ++nKey) {\r
- const int nCommandID = m_Data[nApplicationID].GetCommandID(nCommandType, nKey);\r
- CXkeymacsDll::SetCommandID(nApplicationID, nCommandType, nKey, nCommandID);\r
- if ((nCommandType & CONTROLX) && nCommandID) {\r
- CXkeymacsDll::SetCommandID(nApplicationID, CONTROL, 'X', 1); // Commands[1] is C-x\r
- }\r
+ memset(m_Config.nFunctionID, -1, sizeof(m_Config.nFunctionID));\r
+ for (int nFuncID = 0; nFuncID < CDotXkeymacs::GetFunctionNumber(); ++nFuncID)\r
+ _tcscpy_s(m_Config.szFunctionDefinition[nFuncID], CDotXkeymacs::GetFunctionDefinition(nFuncID));\r
+\r
+ for (int nAppID = 0; nAppID < MAX_APP; ++nAppID) {\r
+ m_Config.nCommandID[nAppID][CONTROL]['X'] = 0; // C-x is unassigned.\r
+ for (int nType = 0; nType < MAX_COMMAND_TYPE; ++nType)\r
+ for (int nKey = 0; nKey < MAX_KEY; ++nKey)\r
+ if ((nType & CONTROLX) && m_Config.nCommandID[nAppID][nType][nKey])\r
+ m_Config.nCommandID[nAppID][CONTROL]['X'] = 1; // C-x is available.\r
+ for (int nFuncID = 0; nFuncID < CDotXkeymacs::GetFunctionNumber(); ++nFuncID)\r
+ for (int nKeyID = 0; nKeyID < CDotXkeymacs::GetKeyNumber(nFuncID, nAppID); ++nKeyID) {\r
+ int nType, nKey;\r
+ CDotXkeymacs::GetKey(nFuncID, nAppID, nKeyID, &nType, &nKey);\r
+ m_Config.nFunctionID[nAppID][nType][nKey] = nFuncID;\r
+ if (nType & CONTROLX)\r
+ m_Config.nCommandID[nAppID][CONTROL]['X'] = 1; // C-x is available.\r
}\r
- }\r
-\r
- for (int nFunctionID = 0; nFunctionID < CDotXkeymacs::GetFunctionNumber(); ++nFunctionID) {\r
- for (int nKeyID = 0; nKeyID < CDotXkeymacs::GetKeyNumber(nFunctionID, nApplicationID); ++nKeyID) {\r
- int nCommandType = 0;\r
- int nKey = 0;\r
- CDotXkeymacs::GetKey(nFunctionID, nApplicationID, nKeyID, &nCommandType, &nKey);\r
- CXkeymacsDll::SetFunctionKey(nFunctionID, nApplicationID, nCommandType, nKey);\r
- if (nCommandType & CONTROLX) {\r
- CXkeymacsDll::SetCommandID(nApplicationID, CONTROL, 'X', 1); // Commands[1] is C-x\r
- }\r
- }\r
- }\r
-\r
- CXkeymacsDll::SetKillRingMax(nApplicationID, m_Data[nApplicationID].GetKillRingMax());\r
- CXkeymacsDll::SetUseDialogSetting(nApplicationID, m_Data[nApplicationID].GetUseDialogSetting());\r
- CXkeymacsDll::SetSettingStyle(nApplicationID, m_Data[nApplicationID].GetSettingStyle());\r
- CXkeymacsDll::SetIgnoreUndefinedMetaCtrl(nApplicationID, m_Data[nApplicationID].GetIgnoreUndefinedMetaCtrl());\r
- CXkeymacsDll::SetIgnoreUndefinedC_x(nApplicationID, m_Data[nApplicationID].GetIgnoreUndefinedC_x());\r
- CXkeymacsDll::SetEnableCUA(nApplicationID, m_Data[nApplicationID].GetEnableCUA());\r
- CXkeymacsDll::Set326Compatible(nApplicationID, m_Data[nApplicationID].Get326Compatible());\r
}\r
+ m_Config.b106Keyboard = Is106Keyboard();\r
+ CXkeymacsDll::SetConfig(m_Config);\r
CXkeymacsApp *pApp = static_cast<CXkeymacsApp *>(AfxGetApp());\r
if (!pApp->IsWow64())\r
return;\r
*pnKey = KeyBind2Key(szKeyBind + _tcslen(CommandType2String(*pnCommandType)));\r
}\r
\r
-CString CProfile::WriteKeyBind(const int nCommandType, const int nKey)\r
+CString CProfile::WriteKeyBind(const int nType, const int nKey)\r
{\r
CString szKeyBind;\r
- szKeyBind.Format(_T("%s%s"), CommandType2String(nCommandType), Key2String(nKey));\r
+ szKeyBind.Format(_T("%s%s"), CommandType2String(nType), Key2String(nKey));\r
return szKeyBind;\r
}\r
\r
int CProfile::KeyBind2CommandType(LPCTSTR szKeyBind)\r
{\r
- for (int nCommandType = MAX_COMMAND_TYPE - 1; nCommandType; --nCommandType) {\r
- if (IsCommandType(nCommandType, szKeyBind)) {\r
- return nCommandType;\r
+ for (int nType = MAX_COMMAND_TYPE - 1; nType; --nType) {\r
+ if (IsCommandType(nType, szKeyBind)) {\r
+ return nType;\r
}\r
}\r
return NONE;\r
return 0;\r
}\r
\r
-LPCTSTR CProfile::CommandType2String(int nCommandType)\r
+LPCTSTR CProfile::CommandType2String(int nType)\r
{\r
- if (nCommandType < 0 || sizeof(CommandTypes) / sizeof(CommandTypes[0]) <= nCommandType) {\r
+ if (nType < 0 || sizeof(CommandTypes) / sizeof(CommandTypes[0]) <= nType) {\r
ASSERT(0);\r
- nCommandType = NONE;\r
+ nType = NONE;\r
}\r
- return CommandTypes[nCommandType].szCommandTypeName;\r
+ return CommandTypes[nType].szName;\r
}\r
\r
LPCTSTR CProfile::Key2String(int nKey)\r
return KeyNames[nKey].name;\r
}\r
\r
-BOOL CProfile::IsCommandType(const int nCommandType, LPCTSTR szKeyBind)\r
+BOOL CProfile::IsCommandType(const int nType, LPCTSTR szKeyBind)\r
{\r
- LPCTSTR szCommandType = CommandType2String(nCommandType);\r
+ LPCTSTR szCommandType = CommandType2String(nType);\r
\r
if (!_tcsnicmp(szKeyBind, szCommandType, _tcslen(szCommandType))) {\r
return TRUE;\r
return FALSE;\r
}\r
\r
-void CProfile::SaveKeyBind(const CString szApplicationName, const int nCommandID, const int nCommandType, const int nKey)\r
+void CProfile::SaveKeyBind(const LPCSTR szAppName, const int nComID, const int nType, const int nKey)\r
{\r
- if (!nCommandID) {\r
+ if (!nComID)\r
return;\r
- }\r
-\r
- CString szCommandName = CCommands::GetCommandName(nCommandID);\r
- if (szCommandName.IsEmpty()) {\r
+ const LPCSTR szComName = CCommands::GetCommandName(nComID);\r
+ if (!szComName[0])\r
return;\r
- }\r
-\r
- SaveKeyBind(szApplicationName, szCommandName, nCommandType, nKey);\r
+ SaveKeyBind(szAppName, szComName, nType, nKey);\r
}\r
\r
-void CProfile::SaveKeyBind(const CString szApplicationName, const CString szCommandName, const int nCommandType, const int nKey)\r
+void CProfile::SaveKeyBind(const LPCSTR szAppName, const LPCSTR szComName, const int nType, const int nKey)\r
{\r
- CString szKeyBind = WriteKeyBind(nCommandType, nKey);\r
- CString szSubKey(MAKEINTRESOURCE(IDS_REGSUBKEY_DATA));\r
- szSubKey += _T("\\") + szApplicationName + _T("\\") + szCommandName;\r
- if (!szKeyBind.IsEmpty()) {\r
+ const CString szKeyBind = WriteKeyBind(nType, nKey);\r
+ CString szSubKey = CString(MAKEINTRESOURCE(IDS_REGSUBKEY_DATA)) + _T("\\") + szAppName + _T("\\") + szComName;\r
+ if (!szKeyBind.IsEmpty())\r
szSubKey += _T("\\") + szKeyBind;\r
- }\r
-\r
HKEY hKey = NULL;\r
- if (RegCreateKeyEx(HKEY_CURRENT_USER, szSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, NULL) == ERROR_SUCCESS) {\r
+ if (RegCreateKeyEx(HKEY_CURRENT_USER, szSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, NULL) == ERROR_SUCCESS)\r
RegCloseKey(hKey);\r
- }\r
}\r
\r
-void CProfile::SaveCommand(const CString szApplicationName, const int nCommandID)\r
+void CProfile::SaveCommand(const LPCSTR szAppName, const int nComID)\r
{\r
- SaveKeyBind(szApplicationName, nCommandID, 0, 0);\r
+ SaveKeyBind(szAppName, nComID, 0, 0);\r
}\r
\r
-void CProfile::AddKeyBind2C_(const CString szApplicationName, const BYTE bVk)\r
+void CProfile::AddKeyBind2C_(const LPCSTR szAppName, const BYTE bVk)\r
{\r
- int nCommandID;\r
- for (nCommandID = 0; nCommandID < MAX_COMMAND; ++nCommandID) {\r
- if (Commands[nCommandID].fCommand == CCommands::C_) {\r
+ int nComID;\r
+ for (nComID = 0; nComID < MAX_COMMAND; ++nComID)\r
+ if (Commands[nComID].fCommand == CCommands::C_)\r
break;\r
- }\r
- }\r
-\r
- SaveKeyBind(szApplicationName, nCommandID, NONE, bVk);\r
+ SaveKeyBind(szAppName, nComID, NONE, bVk);\r
}\r
\r
void CProfile::LevelUp()\r
switch (AfxGetApp()->GetProfileInt(szSection, szEntry, nDefalutLevel)) {\r
case nDefalutLevel:\r
{\r
- for (int nApplicationID = 0; nApplicationID < MAX_APP; ++nApplicationID) {\r
+ for (int nAppID = 0; nAppID < MAX_APP; ++nAppID) {\r
CString szEntry;\r
- szEntry.Format(IDS_REG_ENTRY_APPLICATION, nApplicationID);\r
+ szEntry.Format(IDS_REG_ENTRY_APPLICATION, nAppID);\r
\r
CString szApplicationName;\r
szApplicationName = AfxGetApp()->GetProfileString(CString(MAKEINTRESOURCE(IDS_REG_SECTION_APPLICATION)), szEntry);\r
// Do NOT write break; here.\r
case 1:\r
{\r
- for (int nApplicationID = 0; nApplicationID < MAX_APP; ++nApplicationID) {\r
+ for (int nAppID = 0; nAppID < MAX_APP; ++nAppID) {\r
CString szEntry;\r
- szEntry.Format(IDS_REG_ENTRY_APPLICATION, nApplicationID);\r
+ szEntry.Format(IDS_REG_ENTRY_APPLICATION, nAppID);\r
\r
CString szApplicationName;\r
szApplicationName = AfxGetApp()->GetProfileString(CString(MAKEINTRESOURCE(IDS_REG_SECTION_APPLICATION)), szEntry);\r
// Do NOT write break; here.\r
case 2:\r
{\r
- for (int nApplicationID = 0; nApplicationID < MAX_APP; ++nApplicationID) {\r
+ for (int nAppID = 0; nAppID < MAX_APP; ++nAppID) {\r
CString szEntry;\r
- szEntry.Format(IDS_REG_ENTRY_APPLICATION, nApplicationID);\r
+ szEntry.Format(IDS_REG_ENTRY_APPLICATION, nAppID);\r
\r
CString szApplicationName;\r
szApplicationName = AfxGetApp()->GetProfileString(CString(MAKEINTRESOURCE(IDS_REG_SECTION_APPLICATION)), szEntry);\r
// Do NOT write break; here.\r
case 3:\r
{\r
- for (int nApplicationID = 0; nApplicationID < MAX_APP; ++nApplicationID) {\r
+ for (int nAppID = 0; nAppID < MAX_APP; ++nAppID) {\r
CString szEntry;\r
- szEntry.Format(IDS_REG_ENTRY_APPLICATION, nApplicationID);\r
+ szEntry.Format(IDS_REG_ENTRY_APPLICATION, nAppID);\r
\r
CString szApplicationName;\r
szApplicationName = AfxGetApp()->GetProfileString(CString(MAKEINTRESOURCE(IDS_REG_SECTION_APPLICATION)), szEntry);\r
}\r
\r
// rename original function to remove IDS_REG_ORIGINAL_PREFIX\r
- for (int nFunctionID = 0; nFunctionID < CDotXkeymacs::GetFunctionNumber(); ++nFunctionID) {\r
+ for (int nFuncID = 0; nFuncID < CDotXkeymacs::GetFunctionNumber(); ++nFuncID) {\r
HKEY hKey = NULL;\r
CString szSubKey(MAKEINTRESOURCE(IDS_REGSUBKEY_DATA));\r
- szSubKey += _T("\\") + szApplicationName + _T("\\") + CString(MAKEINTRESOURCE(IDS_REG_ORIGINAL_PREFIX)) + CDotXkeymacs::GetFunctionSymbol(nFunctionID);\r
+ szSubKey += _T("\\") + szApplicationName + _T("\\") + CString(MAKEINTRESOURCE(IDS_REG_ORIGINAL_PREFIX)) + CDotXkeymacs::GetFunctionSymbol(nFuncID);\r
if (RegOpenKeyEx(HKEY_CURRENT_USER, szSubKey, 0, KEY_READ, &hKey) == ERROR_SUCCESS) {\r
// Use registry data\r
TCHAR szKeyBind[128] = {'\0'};\r
DWORD dwKeyBind = sizeof(szKeyBind);\r
FILETIME ft = {'\0'}; // not use\r
for (DWORD dwIndex = 0; RegEnumKeyEx(hKey, dwIndex, szKeyBind, &dwKeyBind, NULL, NULL, NULL, &ft) == ERROR_SUCCESS; ++dwIndex) {\r
- int nCommandType = 0;\r
+ int nType = 0;\r
int nKey = 0;\r
- ReadKeyBind(&nCommandType, &nKey, szKeyBind);\r
- SaveKeyBind(szApplicationName, CDotXkeymacs::GetFunctionSymbol(nFunctionID), nCommandType, nKey);\r
+ ReadKeyBind(&nType, &nKey, szKeyBind);\r
+ SaveKeyBind(szApplicationName, CDotXkeymacs::GetFunctionSymbol(nFuncID), nType, nKey);\r
\r
memset(szKeyBind, 0, sizeof(szKeyBind));\r
dwKeyBind = sizeof(szKeyBind);\r
\r
void CProfile::ClearData(const CString szCurrentApplication)\r
{\r
- int nApplicationID;\r
- for (nApplicationID = 0; nApplicationID < MAX_APP; ++nApplicationID) {\r
- if (m_Data[nApplicationID].GetApplicationName() == szCurrentApplication) {\r
- break;\r
+ for (int nAppID = 0; nAppID < MAX_APP; ++nAppID)\r
+ if (szCurrentApplication == m_Config.szSpecialApp[nAppID]) {\r
+ ZeroMemory(m_Config.nCommandID[nAppID], sizeof(m_Config.nCommandID[nAppID]));\r
+ ZeroMemory(m_Config.szSpecialApp[nAppID], CLASS_NAME_LENGTH);\r
+ return;\r
}\r
- }\r
- if (nApplicationID < MAX_APP) {\r
- m_Data[nApplicationID].ClearAll();\r
- }\r
}\r
\r
// return count of saved settings\r
int CProfile::GetSavedSettingCount()\r
{\r
int nSavedSetting = 0;\r
-\r
- for (int nApplicationID = 0; nApplicationID < MAX_APP; ++nApplicationID) {\r
- CString szApplicationName;\r
- szApplicationName = m_Data[nApplicationID].GetApplicationName();\r
- if (!szApplicationName.IsEmpty()) {\r
+ for (int nAppID = 0; nAppID < MAX_APP; ++nAppID)\r
+ if (m_Config.szSpecialApp[nAppID][0])\r
++nSavedSetting;\r
- }\r
- }\r
-\r
return nSavedSetting;\r
}\r
\r
\r
CString szListItem;\r
for (int i = 0; i < MAX_APP; ++i) {\r
- CString szApplicationName = m_Data[i].GetApplicationName();\r
- CString szApplicationTitle = m_Data[i].GetApplicationTitle();\r
- if (szApplicationName == _T("IME")) // IDS_IME_FILE_NAME\r
+ const LPCTSTR szAppName = m_Config.szSpecialApp[i];\r
+ const LPCTSTR szAppTitle = m_szAppTitle[i];\r
+ if (!szAppName[0] || !_tcscmp(szAppName, _T("IME")))\r
continue;\r
- szListItem.Format(IDS_APPLICATION_LIST_ITEM, szApplicationTitle, szApplicationName);\r
- if (IsNotSameString(cApplicationList, szListItem)\r
- && !IsDefault(szApplicationName)\r
- && !IsDialog(szApplicationName)\r
- && !szApplicationName.IsEmpty()) {\r
+ szListItem.Format(IDS_APPLICATION_LIST_ITEM, szAppTitle, szAppName);\r
+ if (IsNotSameString(cApplicationList, szListItem) &&\r
+ !IsDefault(szAppName) && !IsDialog(szAppName))\r
cApplicationList->AddString(szListItem);\r
- }\r
}\r
\r
- TCHAR szFilename[MAX_PATH];\r
- TCHAR szDescription[WINDOW_TEXT_LENGTH];\r
- GetIMEInfo(szFilename, szDescription);\r
- szListItem.Format(IDS_APPLICATION_LIST_ITEM, szDescription, szFilename);\r
- if (IsNotSameString(cApplicationList, szListItem))\r
- cApplicationList->AddString(szListItem);\r
+ AddIMEInfo(cApplicationList);\r
\r
// Add Dialog\r
cApplicationList->InsertString(0, CString(MAKEINTRESOURCE(IDS_DIALOG_TITLE)));\r
cApplicationList->SelectString(-1, CString(MAKEINTRESOURCE(IDS_DEFAULT_TITLE)));\r
}\r
\r
-void CProfile::GetIMEInfo(const LPTSTR szFilename, const LPTSTR szDescription)\r
+void CProfile::AddIMEInfo(CComboBox *cApplicationList)\r
{\r
- _tcscpy_s(szFilename, MAX_PATH, _T("IME")); // IDS_IME_FILE_NAME;\r
- _tcscpy_s(szDescription, WINDOW_TEXT_LENGTH, _T("Input Method Editor"));\r
- HKL hKL = GetKeyboardLayout(0);\r
- if (!ImmIsIME(hKL))\r
+ const UINT n = GetKeyboardLayoutList(0, NULL);\r
+ if (!n)\r
return;\r
- TCHAR buf[MAX_PATH]; // larger than WINDOW_TEXT_LENGTH\r
- if (ImmGetDescription(hKL, buf, WINDOW_TEXT_LENGTH)) {\r
- _tcscpy_s(szDescription, WINDOW_TEXT_LENGTH, buf);\r
- goto filename;\r
- }\r
- // try TSF\r
- CoInitialize(NULL);\r
- HRESULT hr;\r
- ITfInputProcessorProfiles *pProfiles;\r
- hr = CoCreateInstance(CLSID_TF_InputProcessorProfiles, NULL, CLSCTX_INPROC_SERVER, IID_ITfInputProcessorProfiles, reinterpret_cast<LPVOID*>(&pProfiles));\r
- if (SUCCEEDED(hr)) {\r
- const LANGID langid = GetUserDefaultLangID();\r
- CLSID clsid;\r
- GUID guid;\r
- hr = pProfiles->GetDefaultLanguageProfile(langid, GUID_TFCAT_TIP_KEYBOARD, &clsid, &guid);\r
- if (SUCCEEDED(hr)) {\r
- BSTR bstr;\r
- hr = pProfiles->GetLanguageProfileDescription(clsid, langid, guid, &bstr);\r
- if (SUCCEEDED(hr)) {\r
-#ifdef _MBCS\r
- WideCharToMultiByte(CP_ACP, 0, bstr, -1, szDescription, MAX_PATH, NULL, NULL);\r
-#else\r
- wcscpy_s(szDescription, WINDOW_TEXT_LENGTH, bstr);\r
-#endif\r
- SysFreeString(bstr);\r
- }\r
+ std::vector<HKL> hkls(n);\r
+ GetKeyboardLayoutList(n, &hkls[0]);\r
+ TCHAR szFileName[MAX_PATH];\r
+ TCHAR szDescription[WINDOW_TEXT_LENGTH];\r
+ for (std::vector<HKL>::const_iterator p = hkls.begin(); p != hkls.end(); ++p)\r
+ if (ImmGetDescription(*p, szDescription, WINDOW_TEXT_LENGTH) &&\r
+ ImmGetIMEFileName(*p, szFileName, MAX_PATH)) {\r
+ CString item;\r
+ item.Format(IDS_APPLICATION_LIST_ITEM, szDescription, szFileName);\r
+ if (IsNotSameString(cApplicationList, item))\r
+ cApplicationList->AddString(item);\r
}\r
- pProfiles->Release();\r
- }\r
- CoUninitialize();\r
-filename:\r
- if (ImmGetIMEFileName(hKL, buf, MAX_PATH))\r
- _tcscpy_s(szFilename, MAX_PATH, buf);\r
}\r
\r
void CProfile::GetTaskList()\r
// if there is NOT the application in the data, this function takes care of it.\r
int CProfile::GetApplicationIndex(const CString szApplicationName, const BOOL bSaveAndValidate, int *const nSettingStyle)\r
{\r
- if (!bSaveAndValidate) { // SetDialogData\r
+ if (!bSaveAndValidate) // SetDialogData\r
*nSettingStyle = SETTING_UNDEFINED;\r
- }\r
-\r
- int nApplicationID = GetApplicationIndex(szApplicationName);\r
-\r
- if (nApplicationID == MAX_APP) {\r
- if (bSaveAndValidate) { // GetDialogData\r
- for (nApplicationID = 0; nApplicationID < MAX_APP; ++nApplicationID) {\r
- CString sz = m_Data[nApplicationID].GetApplicationName();\r
- if (sz.IsEmpty()) {\r
- m_Data[nApplicationID].SetApplicationName(szApplicationName);\r
+ int nAppID = GetApplicationIndex(szApplicationName);\r
+ if (nAppID == MAX_APP) {\r
+ if (bSaveAndValidate) { // GetDialogData\r
+ for (nAppID = 0; nAppID < MAX_APP; ++nAppID)\r
+ if (!m_Config.szSpecialApp[nAppID][0]) {\r
+ _tcsncpy_s(m_Config.szSpecialApp[nAppID], szApplicationName, _TRUNCATE);\r
break;\r
}\r
- }\r
- if (nApplicationID == MAX_APP) {\r
- return nApplicationID;\r
- }\r
- } else { // SetDialogData\r
- for (nApplicationID = 0; nApplicationID < MAX_APP; ++nApplicationID) {\r
- if (IsDefault(m_Data[nApplicationID].GetApplicationName())) {\r
+ if (nAppID == MAX_APP)\r
+ return nAppID;\r
+ } else { // SetDialogData\r
+ for (nAppID = 0; nAppID < MAX_APP; ++nAppID)\r
+ if (IsDefault(m_Config.szSpecialApp[nAppID])) {\r
*nSettingStyle = SETTING_DEFAULT;\r
break;\r
}\r
- }\r
- if (nApplicationID == MAX_APP) {\r
- return nApplicationID;\r
- }\r
+ if (nAppID == MAX_APP)\r
+ return nAppID;\r
}\r
}\r
-\r
- if (bSaveAndValidate) { // GetDialogData\r
- m_Data[nApplicationID].SetSettingStyle(*nSettingStyle);\r
- } else { // SetDialogData\r
- if (*nSettingStyle == SETTING_UNDEFINED) { // It means that *nSettingStyle != SETTING_DEFAULT.\r
- *nSettingStyle = m_Data[nApplicationID].GetSettingStyle();\r
- }\r
+ if (bSaveAndValidate) // GetDialogData\r
+ m_Config.nSettingStyle[nAppID] = *nSettingStyle;\r
+ else { // SetDialogData\r
+ if (*nSettingStyle == SETTING_UNDEFINED) // It means that *nSettingStyle != SETTING_DEFAULT.\r
+ *nSettingStyle = m_Config.nSettingStyle[nAppID];\r
}\r
-\r
- return nApplicationID;\r
+ return nAppID;\r
}\r
\r
BOOL CProfile::Is106Keyboard()\r
return;\r
}\r
\r
-void CProfile::UpdateApplicationTitle(CComboBox *const cApplicationList, const CString szCurrentApplication, const int nApplicationID, const BOOL bSaveAndValidate)\r
+void CProfile::UpdateApplicationTitle(CComboBox *const cApplicationList, const CString szCurrentApplication, const int nAppID, const BOOL bSaveAndValidate)\r
{\r
static CString szApplicationTitle;\r
if (bSaveAndValidate) { // GetDialogData\r
- if (!CProfile::IsDefault(szCurrentApplication)) {\r
- m_Data[nApplicationID].SetApplicationTitle(szApplicationTitle);\r
- }\r
+ if (!CProfile::IsDefault(szCurrentApplication))\r
+ _tcsncpy_s(m_szAppTitle[nAppID], szApplicationTitle, _TRUNCATE);\r
szApplicationTitle.Empty();\r
- } else { // SetDialogData\r
+ } else { // SetDialogData\r
CString szListItem;\r
CProfile::GetApplicationTitle(cApplicationList, szListItem);\r
- int nEndTitle = szListItem.ReverseFind(_T('('));\r
- if (nEndTitle > 0) {\r
+ const int nEndTitle = szListItem.ReverseFind(_T('('));\r
+ if (nEndTitle > 0)\r
szApplicationTitle = szListItem.Left(nEndTitle);\r
- }\r
}\r
}\r
\r
-void CProfile::SetCommandID(const int nApplicationID, const int nCommandType, const int nKey, int nCommandID)\r
+void CProfile::SetCommandID(const int nAppID, const int nType, const int nKey, int nComID)\r
{\r
- if (nKey == 0xf0 && Commands[nCommandID].fCommand == CCommands::C_) {\r
+ if (nKey == 0xf0 && Commands[nComID].fCommand == CCommands::C_)\r
// Change CommandID C_Eisu\r
- for (nCommandID = 1; nCommandID < MAX_COMMAND; ++nCommandID) {\r
- if (Commands[nCommandID].fCommand == CCommands::C_Eisu) {\r
+ for (nComID = 1; nComID < MAX_COMMAND; ++nComID)\r
+ if (Commands[nComID].fCommand == CCommands::C_Eisu)\r
break;\r
- }\r
- }\r
- }\r
- m_Data[nApplicationID].SetCommandID(nCommandType, nKey, nCommandID);\r
+ m_Config.nCommandID[nAppID][nType][nKey] = nComID;\r
}\r
\r
-int CProfile::GetCommandID(const int nApplicationID, const int nCommandType, const int nKey)\r
+int CProfile::GetCommandID(const int nAppID, const int nType, const int nKey)\r
{\r
- int nCommandID = m_Data[nApplicationID].GetCommandID(nCommandType, nKey);\r
- if (nKey == 0xf0 && Commands[nCommandID].fCommand == CCommands::C_Eisu) {\r
+ int nComID = m_Config.nCommandID[nAppID][nType][nKey];\r
+ if (nKey == 0xf0 && Commands[nComID].fCommand == CCommands::C_Eisu)\r
// Change CommandID C_\r
- for (nCommandID = 1; nCommandID < MAX_COMMAND; ++nCommandID) {\r
- if (Commands[nCommandID].fCommand == CCommands::C_) {\r
+ for (nComID = 1; nComID < MAX_COMMAND; nComID++)\r
+ if (Commands[nComID].fCommand == CCommands::C_)\r
break;\r
- }\r
- }\r
- }\r
- return nCommandID;\r
+ return nComID;\r
}\r
\r
-void CProfile::SetKillRingMax(const int nApplicationID, const int nKillRingMax)\r
+void CProfile::SetKillRingMax(const int nAppID, const int nKillRingMax)\r
{\r
- m_Data[nApplicationID].SetKillRingMax(nKillRingMax);\r
+ m_Config.nKillRingMax[nAppID] = nKillRingMax;\r
}\r
\r
-int CProfile::GetKillRingMax(const int nApplicationID)\r
+int CProfile::GetKillRingMax(const int nAppID)\r
{\r
- return m_Data[nApplicationID].GetKillRingMax();\r
+ return m_Config.nKillRingMax[nAppID];\r
}\r
\r
-void CProfile::SetUseDialogSetting(const int nApplicationID, const BOOL bUseDialogSetting)\r
+void CProfile::SetUseDialogSetting(const int nAppID, const BOOL bUseDialogSetting)\r
{\r
- m_Data[nApplicationID].SetUseDialogSetting(bUseDialogSetting);\r
+ m_Config.bUseDialogSetting[nAppID] = bUseDialogSetting;\r
}\r
\r
-BOOL CProfile::GetUseDialogSetting(const int nApplicationID)\r
+BOOL CProfile::GetUseDialogSetting(const int nAppID)\r
{\r
- return m_Data[nApplicationID].GetUseDialogSetting();\r
+ return m_Config.bUseDialogSetting[nAppID];\r
}\r
\r
-void CProfile::SetWindowText(const int nApplicationID, const CString szWindowText)\r
+void CProfile::SetWindowText(const int nAppID, const CString szWindowText)\r
{\r
- m_Data[nApplicationID].SetWindowText(szWindowText);\r
+ if (CUtils::GetWindowTextType(szWindowText) == IDS_WINDOW_TEXT_IGNORE)\r
+ _tcscpy_s(m_Config.szWindowText[nAppID], _T("*"));\r
+ else\r
+ _tcsncpy_s(m_Config.szWindowText[nAppID], szWindowText, _TRUNCATE);\r
}\r
\r
-CString CProfile::GetWindowText(const int nApplicationID)\r
+CString CProfile::GetWindowText(const int nAppID)\r
{\r
- return m_Data[nApplicationID].GetWindowText();\r
+ return m_Config.szWindowText[nAppID];\r
}\r
\r
void CProfile::DeleteAllRegistryData()\r
HKEY hkey = NULL;\r
if (RegOpenKeyEx(HKEY_CURRENT_USER, CString(MAKEINTRESOURCE(IDS_REGSUBKEY_DATA)), 0, KEY_ALL_ACCESS, &hkey) == ERROR_SUCCESS) {\r
// I am sure that I have to do only one time, but...\r
- for (int nApplicationID = 0; nApplicationID < MAX_APP; ++nApplicationID) {\r
+ for (int nAppID = 0; nAppID < MAX_APP; ++nAppID) {\r
DWORD dwIndex = 0;\r
TCHAR szName[SUB_KEY_NAME_LENGTH] = {'\0'};\r
DWORD dwName = sizeof(szName);\r
return -1;\r
}\r
\r
-void CProfile::CopyData(const CString szDestinationApplication, const CString szSourceApplication)\r
+void CProfile::CopyData(const CString szDstApp, const CString szSrcApp)\r
{\r
int nSettingStyle = SETTING_SPECIFIC;\r
- int nDestinationApplication = GetApplicationIndex(szDestinationApplication, TRUE, &nSettingStyle);\r
- int nSourceApplication = GetApplicationIndex(szSourceApplication);\r
-\r
- CString szApplicationName = m_Data[nDestinationApplication].GetApplicationName();\r
- CString szApplicationTitle = m_Data[nDestinationApplication].GetApplicationTitle();\r
- CString szWindowText = m_Data[nDestinationApplication].GetWindowText();\r
- int nWindowTextType = m_Data[nDestinationApplication].GetWindowTextType();\r
-\r
- m_Data[nDestinationApplication] = m_Data[nSourceApplication];\r
-\r
- m_Data[nDestinationApplication].SetApplicationName(szApplicationName);\r
- m_Data[nDestinationApplication].SetApplicationTitle(szApplicationTitle);\r
- m_Data[nDestinationApplication].SetWindowText(szWindowText);\r
- m_Data[nDestinationApplication].SetWindowTextType(nWindowTextType);\r
+ const int nDstApp = GetApplicationIndex(szDstApp, TRUE, &nSettingStyle);\r
+ const int nSrcApp = GetApplicationIndex(szSrcApp);\r
+\r
+#define CopyMember(member) CopyMemory(&m_Config. ## member ## [nDstApp], &m_Config. ## member ## [nSrcApp], sizeof(m_Config. ## member ## [nSrcApp]))\r
+ CopyMember(b326Compatible);\r
+ CopyMember(nFunctionID);\r
+ CopyMember(bEnableCUA);\r
+ CopyMember(bUseDialogSetting);\r
+ CopyMember(bIgnoreUndefinedC_x);\r
+ CopyMember(bIgnoreUndefinedMetaCtrl);\r
+ CopyMember(nKillRingMax);\r
+ CopyMember(nCommandID);\r
+#undef CopyMember\r
}\r
\r
// return application index\r
// if there is NOT the application in the data, return MAX_APP\r
int CProfile::GetApplicationIndex(const CString szApplicationName)\r
{\r
- int nApplicationID = 0;\r
- for (nApplicationID = 0; nApplicationID < MAX_APP; ++nApplicationID) {\r
- if (m_Data[nApplicationID].GetApplicationName() == szApplicationName) {\r
+ int nAppID = 0;\r
+ for (nAppID = 0; nAppID < MAX_APP; ++nAppID)\r
+ if (szApplicationName == m_Config.szSpecialApp[nAppID])\r
break;\r
- }\r
- }\r
- return nApplicationID;\r
+ return nAppID;\r
}\r
\r
// Return True if Windows Vista or later.\r
return;\r
}\r
\r
-BOOL CProfile::GetEnableCUA(const int nApplicationID)\r
+BOOL CProfile::GetEnableCUA(const int nAppID)\r
{\r
- return m_Data[nApplicationID].GetEnableCUA();\r
+ return m_Config.bEnableCUA[nAppID];\r
}\r
\r
-void CProfile::SetEnableCUA(const int nApplicationID, const BOOL bEnableCUA)\r
+void CProfile::SetEnableCUA(const int nAppID, const BOOL bEnableCUA)\r
{\r
- m_Data[nApplicationID].SetEnableCUA(bEnableCUA);\r
+ m_Config.bEnableCUA[nAppID] = bEnableCUA;\r
}\r
\r
int CProfile::GetKeyboardSpeed()\r