OSDN Git Service

Separate UpdateRegistryData into LoadRegistry and SaveRegistry in CProfile.
authorKazuhiro Fujieda <fujieda@users.sourceforge.jp>
Mon, 20 Jun 2011 07:05:30 +0000 (16:05 +0900)
committerKazuhiro Fujieda <fujieda@users.sourceforge.jp>
Mon, 20 Jun 2011 07:05:30 +0000 (16:05 +0900)
xkeymacs/profile.cpp
xkeymacs/profile.h

index 44677e7..ff158c9 100644 (file)
@@ -489,260 +489,168 @@ CProfile::~CProfile()
 \r
 }\r
 \r
-// This method initializes data in the registry, or retrieves and validates registry data.\r
-// bSaveAndValidate specifies a flag that indicates \r
-// whether registry data is being initialized (FALSE) or data is being retrieved (TRUE). \r
-void CProfile::UpdateRegistryData(const BOOL bSaveAndValidate)\r
-{\r
-       CString szEntry;\r
-       CString szApplicationName;\r
-       CString szApplicationTitle;\r
-       CString szWindowText;\r
-       CString szWindowTextType;\r
-\r
-       BOOL bUseDialogSetting = FALSE;\r
-\r
-       for (int nApplicationID = 0; nApplicationID < MAX_APP; ++nApplicationID) {\r
-               // application name\r
-               CString szSection(MAKEINTRESOURCE(IDS_REG_SECTION_APPLICATION));\r
-               szEntry.Format(IDS_REG_ENTRY_APPLICATION, nApplicationID);\r
-               if (bSaveAndValidate) { // retrieve\r
-                       m_Data[nApplicationID].ClearAll();\r
-                       szApplicationName = AfxGetApp()->GetProfileString(szSection, szEntry);\r
-                       if (szApplicationName.IsEmpty()) {\r
-                               if (nApplicationID) {\r
-                                       if (!bUseDialogSetting) {\r
-                                               szApplicationName.LoadString(IDS_DIALOG);\r
-                                               bUseDialogSetting = TRUE;\r
-                                       } else {\r
-                                               continue;\r
-                                       }\r
-                               } else {\r
-                                       szApplicationName.LoadString(IDS_DEFAULT);\r
-                               }\r
-                       } else {\r
-                               if (szApplicationName == CString(MAKEINTRESOURCE(IDS_DIALOG))) {\r
-                                       bUseDialogSetting = TRUE;\r
-                               }\r
-                       }\r
-                       m_Data[nApplicationID].SetApplicationName(szApplicationName);\r
-               } else {                                // initialize\r
-                       szApplicationName = m_Data[nApplicationID].GetApplicationName();\r
-                       if (szApplicationName.IsEmpty()) {\r
-                               continue;\r
-                       }\r
-                       AfxGetApp()->WriteProfileString(szSection, szEntry, szApplicationName);\r
-               }\r
-\r
-               // application title\r
-               szEntry.LoadString(IDS_REG_ENTRY_APPLICATOIN_TITLE);\r
-               if (bSaveAndValidate) { // retrieve\r
-                       szApplicationTitle = AfxGetApp()->GetProfileString(szApplicationName, szEntry);\r
-                       m_Data[nApplicationID].SetApplicationTitle(szApplicationTitle);\r
-               } else {                                // initialize\r
-                       szApplicationTitle = m_Data[nApplicationID].GetApplicationTitle();\r
-                       while (!szApplicationTitle.IsEmpty() && szApplicationTitle.GetAt(0) == _T(' ')) {\r
-                               szApplicationTitle.Delete(0);\r
-                       }\r
-                       AfxGetApp()->WriteProfileString(szApplicationName, szEntry, szApplicationTitle);\r
-               }\r
-\r
-               // window text\r
-               szEntry.LoadString(IDS_REG_ENTRY_WINDOW_TEXT);\r
-               if (bSaveAndValidate) { // retrieve\r
-                       szWindowText = AfxGetApp()->GetProfileString(szApplicationName, szEntry, _T("*"));\r
-                       if (szWindowText.IsEmpty()) {\r
-                               szWindowText = _T('*');\r
-                       }\r
-                       m_Data[nApplicationID].SetWindowText(szWindowText);\r
-               } else {                                // initialize\r
-                       szWindowText = m_Data[nApplicationID].GetWindowText();\r
-                       AfxGetApp()->WriteProfileString(szApplicationName, szEntry, szWindowText);\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
-               // window text type\r
-               szEntry.LoadString(IDS_REG_ENTRY_WINDOW_TEXT_TYPE);\r
-               if (bSaveAndValidate) { // retrieve\r
-                       szWindowTextType = AfxGetApp()->GetProfileString(szApplicationName, szEntry);\r
-\r
-                       int nWindowTextType = IDS_WINDOW_TEXT_IGNORE;\r
-                       if (szWindowTextType == CString(MAKEINTRESOURCE(IDS_WINDOW_TEXT_MATCH))) {\r
-                               nWindowTextType = IDS_WINDOW_TEXT_MATCH;\r
-                       } else if (szWindowTextType == CString(MAKEINTRESOURCE(IDS_WINDOW_TEXT_MATCH_FORWARD))) {\r
-                               nWindowTextType = IDS_WINDOW_TEXT_MATCH_FORWARD;\r
-                       } else if (szWindowTextType == CString(MAKEINTRESOURCE(IDS_WINDOW_TEXT_MATCH_BACKWARD))) {\r
-                               nWindowTextType = IDS_WINDOW_TEXT_MATCH_BACKWARD;\r
-                       } else if (szWindowTextType == CString(MAKEINTRESOURCE(IDS_WINDOW_TEXT_MATCH_FULL))) {\r
-                               nWindowTextType = IDS_WINDOW_TEXT_MATCH_FULL;\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
-                       m_Data[nApplicationID].SetWindowTextType(nWindowTextType);\r
-               } else {                                // initialize\r
-                       szWindowTextType.LoadString(m_Data[nApplicationID].GetWindowTextType());\r
-                       AfxGetApp()->WriteProfileString(szApplicationName, szEntry, szWindowTextType);\r
-               }\r
+void CProfile::LoadRegistory()\r
+{\r
+       bool bDialog = false;\r
+       const CString section(MAKEINTRESOURCE(IDS_REG_SECTION_APPLICATION));    \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
+               if (appName.IsEmpty())  {\r
+                       if (nAppID) {\r
+                               if (bDialog)\r
+                                       continue;\r
+                               appName.LoadString(IDS_DIALOG);\r
+                               bDialog = true;\r
+                       } else\r
+                               appName.LoadString(IDS_DEFAULT);\r
+               } else if (appName == CString(MAKEINTRESOURCE(IDS_DIALOG)))\r
+                       bDialog = true;\r
+               m_Data[nAppID].SetApplicationName(appName);\r
+\r
+               entry.LoadString(IDS_REG_ENTRY_APPLICATOIN_TITLE);\r
+               m_Data[nAppID].SetApplicationTitle(AfxGetApp()->GetProfileString(appName, entry));\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("\\") + szApplicationName;\r
-               // on/off\r
-               if (bSaveAndValidate) { // retrieve\r
-                       for (int nCommandID = 1; nCommandID < MAX_COMMAND; ++nCommandID) {\r
-                               szEntry = CCommands::GetCommandName(nCommandID);\r
-                               if (szEntry.IsEmpty()) {\r
-                                       break;\r
-                               }\r
-                               HKEY hKey = NULL;\r
-                               CString regKey = regApp + _T("\\") + szEntry;\r
-                               if (RegOpenKeyEx(HKEY_CURRENT_USER, regKey, 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;\r
-                                                RegEnumKeyEx(hKey, dwIndex, szKeyBind, &dwKeyBind, NULL, NULL, NULL, &ft) == ERROR_SUCCESS;\r
-                                                ++dwIndex) {\r
-                                               int nCommandType = 0;\r
-                                               int nKey = 0;\r
-                                               ReadKeyBind(&nCommandType, &nKey, szKeyBind);\r
-                                               m_Data[nApplicationID].SetCommandID(nCommandType, nKey, nCommandID);\r
-                                               memset(szKeyBind, 0, sizeof(szKeyBind));\r
-                                               dwKeyBind = sizeof(szKeyBind);\r
-                                       }\r
-                                       RegCloseKey(hKey);\r
-                               } else {\r
-                                       // Use default setting\r
-                                       for (int i = 0; ; ++i) {\r
-                                               if (CCommands::GetDefaultControlID(nCommandID, i) == IDC_CO2) {\r
-                                                       continue;\r
-                                               }\r
-\r
-                                               int nCommandType = CCommands::GetDefaultCommandType(nCommandID, i);\r
-                                               int nKey = CCommands::GetDefaultCommandKey(nCommandID, i);\r
-                                               if (nKey == 0) {\r
-                                                       break;\r
-                                               }\r
-                                               m_Data[nApplicationID].SetCommandID(nCommandType, nKey, nCommandID);\r
-                                       }\r
-                               }\r
-                       }\r
-                       for (int nFunctionID = 0; nFunctionID < CDotXkeymacs::GetFunctionNumber(); ++nFunctionID) {\r
-                               HKEY hKey = NULL;\r
-                               CString regKey = regApp + _T("\\") + CDotXkeymacs::GetFunctionSymbol(nFunctionID);\r
-                               if (RegOpenKeyEx(HKEY_CURRENT_USER, regKey, 0, KEY_READ, &hKey) == ERROR_SUCCESS) {\r
-                                       // Use registry data\r
-                                       CDotXkeymacs::ClearKey(nFunctionID, nApplicationID);\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 nKey = 0;\r
-                                               ReadKeyBind(&nCommandType, &nKey, szKeyBind);\r
-                                               CDotXkeymacs::SetKey(nFunctionID, nApplicationID, nCommandType, nKey);\r
-\r
-                                               memset(szKeyBind, 0, sizeof(szKeyBind));\r
-                                               dwKeyBind = sizeof(szKeyBind);\r
-                                       }\r
-                                       RegCloseKey(hKey);\r
-                               }\r
-                       }\r
-               } else {                                // initialize\r
-                       // create all commands\r
-                       for (int nCommandID = 1; nCommandID < MAX_COMMAND; ++nCommandID) {\r
-                               szEntry = CCommands::GetCommandName(nCommandID);\r
-                               if (szEntry.IsEmpty()) {\r
-                                       break;\r
-                               }\r
-\r
-                               SaveCommand(szApplicationName, nCommandID);\r
-                       }\r
-                       for (int nCommandType = 0; nCommandType < MAX_COMMAND_TYPE; ++nCommandType) {\r
-                               for (int nKey = 0; nKey < MAX_KEY; ++nKey) {\r
-                                       int nCommandID = m_Data[nApplicationID].GetCommandID(nCommandType, nKey);\r
-                                       SaveKeyBind(szApplicationName, nCommandID, nCommandType, nKey);\r
+               regApp += _T("\\") + appName;\r
+               for (int nCommandID = 1; nCommandID < MAX_COMMAND; nCommandID++) {\r
+                       entry = CCommands::GetCommandName(nCommandID);\r
+                       HKEY hKey;\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
+                                       dwKeyBind = _countof(szKeyBind);\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
-                                       SaveKeyBind(szApplicationName, CDotXkeymacs::GetFunctionSymbol(nFunctionID), nCommandType, nKey);\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
+                                               continue;\r
+                                       const int nCommandType = CCommands::GetDefaultCommandType(nCommandID, i);\r
+                                       m_Data[nAppID].SetCommandID(nCommandType, nKey, nCommandID);\r
                                }\r
                        }\r
                }\r
-\r
-               // kill-ring-max\r
-               szEntry.LoadString(IDS_REG_ENTRY_KILL_RING_MAX);\r
-               if (bSaveAndValidate) { // retrieve\r
-                       int nKillRingMax = AfxGetApp()->GetProfileInt(szApplicationName, szEntry, 1);\r
-                       m_Data[nApplicationID].SetKillRingMax(nKillRingMax);\r
-               } else {                                // initialize\r
-                       int nKillRingMax = m_Data[nApplicationID].GetKillRingMax();\r
-                       AfxGetApp()->WriteProfileInt(szApplicationName, szEntry, nKillRingMax);\r
-               }\r
-\r
-               // Use Dialog Setting\r
-               szEntry.LoadString(IDS_REG_ENTRY_USE_DIALOG_SETTING);\r
-               if (bSaveAndValidate) { // retrieve\r
-                       BOOL bUseDialogSetting = AfxGetApp()->GetProfileInt(szApplicationName,szEntry, 1);\r
-                       m_Data[nApplicationID].SetUseDialogSetting(bUseDialogSetting);\r
-               } else {                                // initialize\r
-                       BOOL bUseDialogSetting = m_Data[nApplicationID].GetUseDialogSetting();\r
-                       AfxGetApp()->WriteProfileInt(szApplicationName, szEntry, bUseDialogSetting);\r
-               }\r
-\r
-               // Setting Style\r
-               szEntry.LoadString(IDS_REG_ENTRY_DISABLE_XKEYMACS);\r
-               if (bSaveAndValidate) { // retrieve\r
-                       int nSettingStyle = SETTING_DEFAULT;\r
+               for (int nFunctionID = 0; nFunctionID < CDotXkeymacs::GetFunctionNumber(); nFunctionID++) {\r
                        HKEY hKey;\r
-                       if (AfxGetApp()->GetProfileInt(szApplicationName, szEntry, 0) != 0) {\r
-                               nSettingStyle = SETTING_DISABLE;\r
-                       } else if (RegOpenKeyEx(HKEY_CURRENT_USER, regApp, 0, KEY_READ, &hKey) == ERROR_SUCCESS) {\r
+                       const CString regKey = regApp + _T("\\") + CDotXkeymacs::GetFunctionSymbol(nFunctionID);\r
+                       if (RegOpenKeyEx(HKEY_CURRENT_USER, regKey, 0, KEY_READ, &hKey) == ERROR_SUCCESS) {\r
+                               CDotXkeymacs::ClearKey(nFunctionID, 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
+                                       dwKeyBind = _countof(szKeyBind);\r
+                               }\r
                                RegCloseKey(hKey);\r
-                               nSettingStyle = SETTING_SPECIFIC;\r
                        }\r
-                       m_Data[nApplicationID].SetSettingStyle(nSettingStyle);\r
-               } else {                                // initialize\r
-                       BOOL bDisableXkeymacs = FALSE;\r
-                       if (m_Data[nApplicationID].GetSettingStyle() == SETTING_DISABLE) {\r
-                               bDisableXkeymacs = TRUE;\r
-                       }\r
-                       AfxGetApp()->WriteProfileInt(szApplicationName, szEntry, bDisableXkeymacs);\r
                }\r
 \r
-               // Ignore Meta Ctrl+? when it is undefined.\r
-               szEntry.LoadString(IDC_REG_ENTRY_IGNORE_META_CTRL);\r
-               if (bSaveAndValidate) { // retrieve\r
-                       m_Data[nApplicationID].SetIgnoreUndefinedMetaCtrl(AfxGetApp()->GetProfileInt(szApplicationName, szEntry, 0));\r
-               } else {                                // initialize\r
-                       AfxGetApp()->WriteProfileInt(szApplicationName, szEntry, m_Data[nApplicationID].GetIgnoreUndefinedMetaCtrl());\r
+               entry.LoadString(IDS_REG_ENTRY_KILL_RING_MAX);\r
+               m_Data[nAppID].SetKillRingMax(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
+               \r
+               int nSettingStyle = SETTING_DEFAULT;\r
+               HKEY hKey;\r
+               entry.LoadString(IDS_REG_ENTRY_DISABLE_XKEYMACS);\r
+               if (AfxGetApp()->GetProfileInt(appName, entry, 0))\r
+                       nSettingStyle = SETTING_DISABLE;\r
+               else if (RegOpenKeyEx(HKEY_CURRENT_USER, regApp, 0, KEY_READ, &hKey) == ERROR_SUCCESS) {\r
+                       RegCloseKey(hKey);\r
+                       nSettingStyle = SETTING_SPECIFIC;\r
                }\r
+               m_Data[nAppID].SetSettingStyle(nSettingStyle);\r
+\r
+               entry.LoadString(IDC_REG_ENTRY_IGNORE_META_CTRL);\r
+               m_Data[nAppID].SetIgnoreUndefinedMetaCtrl(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
+               entry.LoadString(IDC_REG_ENTRY_ENABLE_CUA);\r
+               m_Data[nAppID].SetEnableCUA(AfxGetApp()->GetProfileInt(appName, entry, 0));\r
+               entry.LoadString(IDS_REG_ENTRY_326_COMPATIBLE);\r
+               m_Data[nAppID].Set326Compatible(AfxGetApp()->GetProfileInt(appName, entry, 0));\r
+       }\r
+}\r
 \r
-               // Ignore C-x ? when it is undefined.\r
-               szEntry.LoadString(IDC_REG_ENTRY_IGNORE_C_X);\r
-               if (bSaveAndValidate) { // retrieve\r
-                       m_Data[nApplicationID].SetIgnoreUndefinedC_x(AfxGetApp()->GetProfileInt(szApplicationName, szEntry, 0));\r
-               } else {                                // initialize\r
-                       AfxGetApp()->WriteProfileInt(szApplicationName, szEntry, m_Data[nApplicationID].GetIgnoreUndefinedC_x());\r
-               }\r
+void CProfile::SaveRegistory()\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
+               if (appName.IsEmpty())\r
+                       continue;\r
+               CString entry;\r
+               entry.Format(IDS_REG_ENTRY_APPLICATION, nAppID);\r
+               AfxGetApp()->WriteProfileString(section, entry, appName);\r
+\r
+               entry.LoadString(IDS_REG_ENTRY_APPLICATOIN_TITLE);\r
+               CString appTitle = m_Data[nAppID].GetApplicationTitle();\r
+               appTitle.TrimLeft(_T(' '));\r
+               AfxGetApp()->WriteProfileString(appName, 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
 \r
-               // Enable CUA-mode\r
-               szEntry.LoadString(IDC_REG_ENTRY_ENABLE_CUA);\r
-               if (bSaveAndValidate) { // retrieve\r
-                       m_Data[nApplicationID].SetEnableCUA(AfxGetApp()->GetProfileInt(szApplicationName, szEntry, 0));\r
-               } else {                                // initialize\r
-                       AfxGetApp()->WriteProfileInt(szApplicationName, szEntry, m_Data[nApplicationID].GetEnableCUA());\r
-               }\r
+               CString regApp(MAKEINTRESOURCE(IDS_REGSUBKEY_DATA));\r
+               regApp += _T("\\") + appName;\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
+                       }\r
 \r
-               // Version 3.26 compatible mode\r
-               szEntry.LoadString(IDS_REG_ENTRY_326_COMPATIBLE);\r
-               if (bSaveAndValidate) { // retrieve\r
-                       m_Data[nApplicationID].Set326Compatible(AfxGetApp()->GetProfileInt(szApplicationName, szEntry, 0));\r
-               } else {                                // initialize\r
-                       AfxGetApp()->WriteProfileInt(szApplicationName, szEntry, m_Data[nApplicationID].Get326Compatible());\r
-               }\r
+               entry.LoadString(IDS_REG_ENTRY_KILL_RING_MAX);\r
+               AfxGetApp()->WriteProfileInt(appName, entry, m_Data[nAppID].GetKillRingMax());\r
+               entry.LoadString(IDS_REG_ENTRY_USE_DIALOG_SETTING);\r
+               AfxGetApp()->WriteProfileInt(appName, entry, m_Data[nAppID].GetUseDialogSetting());\r
+               entry.LoadString(IDS_REG_ENTRY_DISABLE_XKEYMACS);\r
+               AfxGetApp()->WriteProfileInt(appName, entry, m_Data[nAppID].GetSettingStyle() == SETTING_DISABLE);\r
+               entry.LoadString(IDC_REG_ENTRY_IGNORE_META_CTRL);\r
+               AfxGetApp()->WriteProfileInt(appName, entry, m_Data[nAppID].GetIgnoreUndefinedMetaCtrl());\r
+               entry.LoadString(IDC_REG_ENTRY_IGNORE_C_X);\r
+               AfxGetApp()->WriteProfileInt(appName, entry, m_Data[nAppID].GetIgnoreUndefinedC_x());\r
+               entry.LoadString(IDC_REG_ENTRY_ENABLE_CUA);\r
+               AfxGetApp()->WriteProfileInt(appName, entry, m_Data[nAppID].GetEnableCUA());\r
+               entry.LoadString(IDS_REG_ENTRY_326_COMPATIBLE);\r
+               AfxGetApp()->WriteProfileInt(appName, entry, m_Data[nAppID].Get326Compatible());\r
        }\r
 }\r
 \r
@@ -750,13 +658,13 @@ void CProfile::LoadData()
 {\r
        CDotXkeymacs::Load();\r
        LevelUp();\r
-       UpdateRegistryData(TRUE);\r
+       LoadRegistory();\r
 }\r
 \r
 void CProfile::SaveData()\r
 {\r
        DeleteAllRegistryData();\r
-       UpdateRegistryData(FALSE);\r
+       SaveRegistory();\r
        SetDllData();\r
 }\r
 \r
index f12552f..08e221e 100644 (file)
@@ -61,8 +61,8 @@ public:
        static int GetSavedSettingCount();\r
        static void ClearData(CString szCurrentApplication);\r
        static void InitDllData();\r
-       static void SaveData();\r
        static void LoadData();\r
+       static void SaveData();\r
        CProfile();\r
        virtual ~CProfile();\r
 \r
@@ -91,7 +91,8 @@ private:
        static int KeyBind2Key(LPCTSTR szKey);\r
        static int KeyBind2CommandType(LPCTSTR szKeyBind);\r
        static CString WriteKeyBind(int nCommandType, int nKey);\r
-       static void UpdateRegistryData(BOOL bSaveAndValidate);\r
+       static void LoadRegistory();\r
+       static void SaveRegistory();\r
 };\r
 \r
 #endif // !defined(AFX_PROFILE_H__9415254D_4656_484B_A730_E02580D8A221__INCLUDED_)\r