#include "Profile.h"\r
#include "MainFrm.h"\r
#include "DotXkeymacs.h"\r
-#include <Imm.h>\r
+#include "imelist.h"\r
#include <Shlwapi.h>\r
#include <TlHelp32.h>\r
-#include <vector>\r
\r
#ifdef _DEBUG\r
#undef THIS_FILE\r
TASK_LIST CProfile::m_TaskList[MAX_TASKS];\r
DWORD CProfile::m_dwTasks;\r
\r
-enum { INITIAL_SIZE = 51200 };\r
-enum { EXTEND_SIZE = 25600 };\r
-\r
-void CProfile::Item2AppName(CString *const sz)\r
-{\r
- if (IsTheString(*sz, IDS_DEFAULT_TITLE)) {\r
- sz->LoadString(IDS_DEFAULT);\r
- }\r
-\r
- if (IsTheString(*sz, IDS_DIALOG_TITLE)) {\r
- sz->LoadString(IDS_DIALOG);\r
- }\r
-\r
- int nStart, nEnd, nCount;\r
-\r
- nStart = sz->ReverseFind(_T('(')) + 1;\r
- nEnd = sz->Find(_T(')'), nStart) - 1;\r
- nCount = (nEnd + 1) - nStart;\r
- *sz = sz->Mid(nStart, nCount);\r
-}\r
-\r
-int CProfile::IsNotSameString(CComboBox *const pApplication, const CString szListItem)\r
-{\r
- CString szItem, szList;\r
- szList = szListItem;\r
- Item2AppName(&szList);\r
-\r
- for (int i = 0; i < pApplication->GetCount(); ++i) {\r
- pApplication->GetLBText(i, szItem);\r
- Item2AppName(&szItem);\r
- if (!_tcsicmp(szItem, szList)) {\r
- return 0;\r
- }\r
- }\r
-\r
- return 1;\r
-}\r
-\r
-int CProfile::CountSeparator(const CString szMainString, const CString szSeparator)\r
+// This function returns the nth string in a window name separated by " - ".\r
+// If there aren't a sufficient number of strings, it returns the last string\r
+// appropriate for the title.\r
+bool CProfile::GetAppTitle(CString& appTitle, const CString& windowName, int nth)\r
{\r
- int index = 0;\r
- int counter = 0;\r
-\r
- while ((index = szMainString.Find(szSeparator, index)) != -1) {\r
- ++index;\r
- ++counter;\r
+ const CString sep(MAKEINTRESOURCE(IDS_SEPARATE_WINDOWTITLE));\r
+ const int nSep = windowName.Find(sep);\r
+ if (nSep < 0) {\r
+ appTitle = windowName;\r
+ return false;\r
}\r
-\r
- return counter;\r
-}\r
-\r
-void CProfile::GetNthString(CString *const szAppName, const CString szWindowName, const CString szSeparator, int n)\r
-{\r
- int index = -1;\r
-\r
- while (--n) {\r
- index = szWindowName.Find(szSeparator, index + 1);\r
- }\r
-\r
- int nStart;\r
- if (index != -1) {\r
- nStart = index + szSeparator.GetLength();\r
- } else {\r
- nStart = 0;\r
- }\r
-\r
- int nEnd = szWindowName.Find(szSeparator, nStart);\r
- if (nEnd == -1) {\r
- nEnd = szWindowName.GetLength();\r
- }\r
-\r
- *szAppName = szWindowName.Mid(nStart, nEnd - nStart);\r
-}\r
-\r
-void CProfile::GetAppName(CString *const szAppName, LPCTSTR pWindowName)\r
-{\r
- CString szWindowName(pWindowName);\r
- CString szSeparator(MAKEINTRESOURCE(IDS_SEPARATE_WINDOWTITLE));\r
- int nWord = CountSeparator(szWindowName, szSeparator) + 1;\r
-\r
- while (nWord) {\r
- GetNthString(szAppName, szWindowName, szSeparator, nWord);\r
- if (szAppName->GetAt(0) == _T('[')\r
- || szAppName->Find(_T('.'), 0) != -1 // for Microsoft Project\r
- || szAppName->Find(_T(']'), 0) != -1) { // for the file name like [foo - bar]\r
- --nWord;\r
- } else {\r
- return;\r
- }\r
- }\r
-\r
- *szAppName = szWindowName;\r
+ if (GetAppTitle(appTitle, windowName.Right(windowName.GetLength() - nSep - sep.GetLength()), --nth) ||\r
+ !nth || nth > 0 && appTitle.GetAt(0) != _T('[') && appTitle.FindOneOf(_T(".]")) == -1)\r
+ return true;\r
+ appTitle = windowName.Left(nSep);\r
+ return false;\r
}\r
\r
BOOL CALLBACK CProfile::EnumWindowsProc(const HWND hWnd, const LPARAM lParam)\r
{\r
- CComboBox *pApplication = (CComboBox*)lParam;\r
- PTASK_LIST pTask = CProfile::m_TaskList;\r
+ CProperties *pProperties = reinterpret_cast<CProperties*>(lParam);\r
+ PTASK_LIST pTask = CProfile::m_TaskList;\r
\r
TCHAR szWindowName[WINDOW_TEXT_LENGTH];\r
TCHAR szClassName[CLASS_NAME_LENGTH];\r
::GetWindowText(hWnd, szWindowName, sizeof(szWindowName));\r
GetClassName(hWnd, szClassName, sizeof(szClassName));\r
\r
- CString szAppName;\r
+ CString appTitle;\r
// Get Process Name\r
DWORD dwProcessId = 0;\r
GetWindowThreadProcessId(hWnd, &dwProcessId);\r
continue;\r
}\r
if (!_tcsnicmp(pTask[i].ProcessName, CString(MAKEINTRESOURCE(IDS_B2)), sizeof(pTask[i].ProcessName))) {\r
- szAppName.LoadString(IDS_BECKY);\r
+ appTitle.LoadString(IDS_BECKY);\r
} else if (!_tcsnicmp(pTask[i].ProcessName, CString(MAKEINTRESOURCE(IDS_EXPLORER)), sizeof(pTask[i].ProcessName))) {\r
- szAppName.LoadString(IDS_PROGRAM_MANAGER);\r
+ appTitle.LoadString(IDS_PROGRAM_MANAGER);\r
} else if (!_tcsnicmp(pTask[i].ProcessName, CString(MAKEINTRESOURCE(IDS_MSIMN)), sizeof(pTask[i].ProcessName))) {\r
- szAppName.LoadString(IDS_OUTLOOK_EXPRESS);\r
+ appTitle.LoadString(IDS_OUTLOOK_EXPRESS);\r
} else if (!_tcsnicmp(pTask[i].ProcessName, CString(MAKEINTRESOURCE(IDS_PROJECT)), sizeof(pTask[i].ProcessName))\r
|| !_tcsnicmp(pTask[i].ProcessName, CString(MAKEINTRESOURCE(IDS_EXCEL)), sizeof(pTask[i].ProcessName))\r
|| !_tcsnicmp(pTask[i].ProcessName, _T("psp.exe"), sizeof(pTask[i].ProcessName))) {\r
- GetNthString(&szAppName, szWindowName, CString(MAKEINTRESOURCE(IDS_SEPARATE_WINDOWTITLE)), 1);\r
+ GetAppTitle(appTitle, szWindowName, 1);\r
} else if (!_tcsnicmp(pTask[i].ProcessName, _T("sakura.exe"), sizeof(pTask[i].ProcessName))) {\r
- GetNthString(&szAppName, szWindowName, CString(MAKEINTRESOURCE(IDS_SEPARATE_WINDOWTITLE)), 2); // '.' is included, so...\r
+ GetAppTitle(appTitle, szWindowName, 2); // '.' is included, so...\r
} else if (!_tcsnicmp(pTask[i].ProcessName, CString(MAKEINTRESOURCE(IDS_MSDN)), sizeof(pTask[i].ProcessName))) {\r
- szAppName = szWindowName;\r
+ appTitle = szWindowName;\r
} else if (!_tcsnicmp(pTask[i].ProcessName, _T("devenv.exe"), sizeof(pTask[i].ProcessName))) {\r
- szAppName.Format(_T("Microsoft Visual Studio .NET"));\r
+ appTitle.Format(_T("Microsoft Visual Studio .NET"));\r
} else if (!_tcsnicmp(pTask[i].ProcessName, _T("vb6.exe"), sizeof(pTask[i].ProcessName))) {\r
- szAppName.Format(_T("Microsoft Visual Basic"));\r
+ appTitle.Format(_T("Microsoft Visual Basic"));\r
} else if (!_tcsnicmp(pTask[i].ProcessName, _T("ssexp.exe"), sizeof(pTask[i].ProcessName))) {\r
- szAppName.LoadString(IDS_VISUAL_SOURCESAFE_EXPLORER);\r
+ appTitle.LoadString(IDS_VISUAL_SOURCESAFE_EXPLORER);\r
} else if (!_tcsnicmp(pTask[i].ProcessName, _T("sh.exe"), sizeof(pTask[i].ProcessName))) {\r
- szAppName.Format(_T("MKS Korn Shell"));\r
+ appTitle.Format(_T("MKS Korn Shell"));\r
} else if (!_tcsnicmp(pTask[i].ProcessName, _T("csh.exe"), sizeof(pTask[i].ProcessName))) {\r
- szAppName.Format(_T("C Shell"));\r
+ appTitle.Format(_T("C Shell"));\r
} else if (!_tcsnicmp(pTask[i].ProcessName, _T("vim.exe"), sizeof(pTask[i].ProcessName))) {\r
- szAppName.Format(_T("VIM"));\r
+ appTitle.Format(_T("VIM"));\r
} else {\r
CUtils::SetCorrectApplicationName(pTask[i].ProcessName, szWindowName);\r
- GetAppName(&szAppName, szWindowName);\r
+ GetAppTitle(appTitle, szWindowName);\r
}\r
break;\r
}\r
}\r
\r
- \r
- if ((IsWindowVisible(hWnd)) // Is visible?\r
- && (GetWindow(hWnd, GW_OWNER) == NULL) // Is top level window?\r
- && (lstrlen(szWindowName) > 0) // Have caption?\r
- && (pApplication->FindString(-1, szClassName) == CB_ERR)) {// Is not same string?\r
- CString szListItem;\r
- szListItem.Format(IDS_APPLICATION_LIST_ITEM, szAppName, pTask[i].ProcessName);\r
- if (IsNotSameString(pApplication, szListItem)) {\r
- pApplication->AddString(szListItem);\r
- }\r
+ if (IsWindowVisible(hWnd) && // Is visible?\r
+ GetWindow(hWnd, GW_OWNER) == NULL && // Is top level window?\r
+ lstrlen(szWindowName) > 0) { // Have caption?\r
+ pProperties->AddItem(appTitle, pTask[i].ProcessName);\r
}\r
return TRUE;\r
}\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
+ for (BYTE nComID = 1; nComID < MAX_COMMAND; ++nComID) {\r
entry = CCommands::GetCommandName(nComID);\r
HKEY hKey;\r
const CString regKey = regApp + _T("\\") + entry;\r
}\r
\r
entry.LoadString(IDS_REG_ENTRY_KILL_RING_MAX);\r
- m_Config.nKillRingMax[nAppID] = AfxGetApp()->GetProfileInt(appName, entry, 1);\r
+ int n = AfxGetApp()->GetProfileInt(appName, entry, 1);\r
+ m_Config.nKillRingMax[nAppID] = static_cast<BYTE>(n > 255 ? 255 : n);\r
entry.LoadString(IDS_REG_ENTRY_USE_DIALOG_SETTING);\r
- m_Config.bUseDialogSetting[nAppID] = AfxGetApp()->GetProfileInt(appName, entry, 1);\r
+ m_Config.bUseDialogSetting[nAppID] = static_cast<BYTE>(AfxGetApp()->GetProfileInt(appName, entry, 1));\r
entry.LoadString(IDS_REG_ENTRY_DISABLE_XKEYMACS);\r
- m_Config.nSettingStyle[nAppID] = AfxGetApp()->GetProfileInt(appName, entry, 0) ? SETTING_DISABLE : SETTING_SPECIFIC;\r
+ m_Config.nSettingStyle[nAppID] = static_cast<BYTE>(AfxGetApp()->GetProfileInt(appName, entry, 0) ? SETTING_DISABLE : SETTING_SPECIFIC);\r
entry.LoadString(IDC_REG_ENTRY_IGNORE_META_CTRL);\r
- m_Config.bIgnoreUndefinedMetaCtrl[nAppID] = AfxGetApp()->GetProfileInt(appName, entry, 0);\r
+ m_Config.bIgnoreUndefinedMetaCtrl[nAppID] = static_cast<BYTE>(AfxGetApp()->GetProfileInt(appName, entry, 0));\r
entry.LoadString(IDC_REG_ENTRY_IGNORE_C_X);\r
- m_Config.bIgnoreUndefinedC_x[nAppID] = AfxGetApp()->GetProfileInt(appName, entry, 0);\r
+ m_Config.bIgnoreUndefinedC_x[nAppID] = static_cast<BYTE>(AfxGetApp()->GetProfileInt(appName, entry, 0));\r
entry.LoadString(IDC_REG_ENTRY_ENABLE_CUA);\r
- m_Config.bEnableCUA[nAppID] = AfxGetApp()->GetProfileInt(appName, entry, 0);\r
+ m_Config.bEnableCUA[nAppID] = static_cast<BYTE>(AfxGetApp()->GetProfileInt(appName, entry, 0));\r
entry.LoadString(IDS_REG_ENTRY_326_COMPATIBLE);\r
- m_Config.b326Compatible[nAppID] = AfxGetApp()->GetProfileInt(appName, entry, 0);\r
+ m_Config.b326Compatible[nAppID] = static_cast<BYTE>(AfxGetApp()->GetProfileInt(appName, entry, 0));\r
}\r
}\r
\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 (BYTE 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.nCommandID[nAppID][CONTROL]['X'] = 1; // C-x is available.\r
}\r
}\r
- m_Config.b106Keyboard = Is106Keyboard();\r
+ m_Config.b106Keyboard = static_cast<BYTE>(Is106Keyboard());\r
CXkeymacsDll::SetConfig(m_Config);\r
CXkeymacsApp *pApp = static_cast<CXkeymacsApp *>(AfxGetApp());\r
if (!pApp->IsWow64())\r
\r
void CProfile::LevelUp()\r
{\r
- const int nDefalutLevel = 0;\r
- const int nLatestLevel = 4;\r
-\r
- CString szSection;\r
- CString szEntry;\r
- szEntry.Format(_T("Level"));\r
-\r
- switch (AfxGetApp()->GetProfileInt(szSection, szEntry, nDefalutLevel)) {\r
- case nDefalutLevel:\r
- {\r
- for (int nAppID = 0; nAppID < MAX_APP; ++nAppID) {\r
- CString szEntry;\r
- szEntry.Format(IDS_REG_ENTRY_APPLICATION, nAppID);\r
-\r
- CString szApplicationName;\r
- szApplicationName = AfxGetApp()->GetProfileString(CString(MAKEINTRESOURCE(IDS_REG_SECTION_APPLICATION)), szEntry);\r
- if (szApplicationName.IsEmpty()) {\r
- continue;\r
- }\r
-\r
- AddKeyBind2C_(szApplicationName, VK_LCONTROL);\r
- AddKeyBind2C_(szApplicationName, VK_RCONTROL);\r
- }\r
- }\r
- // Do NOT write break; here.\r
- case 1:\r
- {\r
- for (int nAppID = 0; nAppID < MAX_APP; ++nAppID) {\r
- CString szEntry;\r
- szEntry.Format(IDS_REG_ENTRY_APPLICATION, nAppID);\r
-\r
- CString szApplicationName;\r
- szApplicationName = AfxGetApp()->GetProfileString(CString(MAKEINTRESOURCE(IDS_REG_SECTION_APPLICATION)), szEntry);\r
- if (szApplicationName.IsEmpty()) {\r
- continue;\r
- }\r
-\r
- // Set kill-ring-max 1 if it is 0.\r
- if (!AfxGetApp()->GetProfileInt(szApplicationName, CString(MAKEINTRESOURCE(IDS_REG_ENTRY_KILL_RING_MAX)), 0)) {\r
- AfxGetApp()->WriteProfileInt(szApplicationName, CString(MAKEINTRESOURCE(IDS_REG_ENTRY_KILL_RING_MAX)), 1);\r
- }\r
- }\r
- }\r
- // Do NOT write break; here.\r
- case 2:\r
- {\r
- for (int nAppID = 0; nAppID < MAX_APP; ++nAppID) {\r
- CString szEntry;\r
- szEntry.Format(IDS_REG_ENTRY_APPLICATION, nAppID);\r
-\r
- CString szApplicationName;\r
- szApplicationName = AfxGetApp()->GetProfileString(CString(MAKEINTRESOURCE(IDS_REG_SECTION_APPLICATION)), szEntry);\r
- if (szApplicationName.IsEmpty()) {\r
- continue;\r
- }\r
-\r
+ const int nCurrentLevel = AfxGetApp()->GetProfileInt(_T(""), _T("Level"), 0);\r
+ for (int nAppID = 0; nAppID < MAX_APP; ++nAppID) {\r
+ CString entry;\r
+ entry.Format(IDS_REG_ENTRY_APPLICATION, nAppID);\r
+ const CString appName = AfxGetApp()->GetProfileString(CString(MAKEINTRESOURCE(IDS_REG_SECTION_APPLICATION)), entry);\r
+ if (appName.IsEmpty())\r
+ continue;\r
+ switch (nCurrentLevel) {\r
+ case 0:\r
+ AddKeyBind2C_(appName, VK_LCONTROL);\r
+ AddKeyBind2C_(appName, VK_RCONTROL);\r
+ // fall through\r
+ case 1:\r
+ // Set kill-ring-max 1 if it is 0.\r
+ if (!AfxGetApp()->GetProfileInt(appName, CString(MAKEINTRESOURCE(IDS_REG_ENTRY_KILL_RING_MAX)), 0))\r
+ AfxGetApp()->WriteProfileInt(appName, CString(MAKEINTRESOURCE(IDS_REG_ENTRY_KILL_RING_MAX)), 1);\r
+ // fall through\r
+ case 2:\r
+ {\r
// Chaged a label from Enter to newline.\r
- CString szSrcSubKey(MAKEINTRESOURCE(IDS_REGSUBKEY_DATA));\r
- szSrcSubKey += _T("\\") + szApplicationName + _T("\\") + _T("Enter");\r
- CString szDestSubKey(MAKEINTRESOURCE(IDS_REGSUBKEY_DATA));\r
- szDestSubKey += _T("\\") + szApplicationName + _T("\\") + _T("newline");\r
- HKEY hKeyDest = NULL;\r
- if (RegCreateKeyEx(HKEY_CURRENT_USER, szDestSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKeyDest, NULL) == ERROR_SUCCESS) {\r
- SHCopyKey(HKEY_CURRENT_USER, szSrcSubKey, hKeyDest, NULL);\r
- SHDeleteKey(HKEY_CURRENT_USER, szSrcSubKey);\r
- RegCloseKey(hKeyDest);\r
+ const CString subKey = CString(MAKEINTRESOURCE(IDS_REGSUBKEY_DATA)) + _T("\\") + appName;\r
+ const CString srcKey = subKey + _T("\\") + _T("Enter");\r
+ const CString dstKey = subKey + _T("\\") + _T("newline");\r
+ HKEY hDstKey = NULL;\r
+ if (RegCreateKeyEx(HKEY_CURRENT_USER, dstKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hDstKey, NULL) == ERROR_SUCCESS) {\r
+ SHCopyKey(HKEY_CURRENT_USER, srcKey, hDstKey, NULL);\r
+ SHDeleteKey(HKEY_CURRENT_USER, srcKey);\r
+ RegCloseKey(hDstKey);\r
}\r
}\r
- }\r
- // Do NOT write break; here.\r
- case 3:\r
- {\r
- for (int nAppID = 0; nAppID < MAX_APP; ++nAppID) {\r
- CString szEntry;\r
- szEntry.Format(IDS_REG_ENTRY_APPLICATION, nAppID);\r
-\r
- CString szApplicationName;\r
- szApplicationName = AfxGetApp()->GetProfileString(CString(MAKEINTRESOURCE(IDS_REG_SECTION_APPLICATION)), szEntry);\r
- if (szApplicationName.IsEmpty()) {\r
- continue;\r
- }\r
-\r
- // rename original function to remove IDS_REG_ORIGINAL_PREFIX\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(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 nType, 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
- RegCloseKey(hKey);\r
+ // fall through\r
+ case 3:\r
+ // rename original function to remove IDS_REG_ORIGINAL_PREFIX\r
+ for (int nFuncID = 0; nFuncID < CDotXkeymacs::GetFunctionNumber(); ++nFuncID) {\r
+ HKEY hKey = NULL;\r
+ const CString subKey = CString(MAKEINTRESOURCE(IDS_REGSUBKEY_DATA)) + _T("\\") + appName + _T("\\") + CString(MAKEINTRESOURCE(IDS_REG_ORIGINAL_PREFIX)) + CDotXkeymacs::GetFunctionSymbol(nFuncID);\r
+ if (RegOpenKeyEx(HKEY_CURRENT_USER, subKey, 0, KEY_READ, &hKey) == ERROR_SUCCESS) {\r
+ // Use registry data\r
+ TCHAR szKeyBind[128];\r
+ DWORD dwKeyBind = sizeof(szKeyBind);\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
+ SaveKeyBind(appName, CDotXkeymacs::GetFunctionSymbol(nFuncID), nType, nKey);\r
+ dwKeyBind = sizeof(szKeyBind);\r
}\r
+ RegCloseKey(hKey);\r
}\r
}\r
}\r
-// case 4:\r
-// foo();\r
-// ...\r
-// case nLatestLevel-1:\r
-// bar();\r
- AfxGetApp()->WriteProfileInt(szSection, szEntry, nLatestLevel);\r
- break;\r
- default:\r
- break;\r
}\r
+ AfxGetApp()->WriteProfileInt(_T(""), _T("Level"), 4);\r
}\r
\r
void CProfile::InitDllData()\r
return nSavedSetting;\r
}\r
\r
-void CProfile::InitApplicationList(CComboBox *const cApplicationList)\r
+void CProfile::InitAppList(CProperties& cProperties)\r
{\r
- cApplicationList->ResetContent();\r
-\r
GetTaskList();\r
\r
- EnumWindows(EnumWindowsProc, (LPARAM)cApplicationList);\r
+ EnumWindows(EnumWindowsProc, reinterpret_cast<LPARAM>(&cProperties));\r
\r
- CString szListItem;\r
for (int i = 0; i < MAX_APP; ++i) {\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, szAppTitle, szAppName);\r
- if (IsNotSameString(cApplicationList, szListItem) &&\r
- !IsDefault(szAppName) && !IsDialog(szAppName))\r
- cApplicationList->AddString(szListItem);\r
+ if (CString(MAKEINTRESOURCE(IDS_DEFAULT)) == szAppName ||\r
+ CString(MAKEINTRESOURCE(IDS_DIALOG)) == szAppName)\r
+ continue;\r
+ cProperties.AddItem(szAppTitle, szAppName);\r
}\r
-\r
- AddIMEInfo(cApplicationList);\r
-\r
- // Add Dialog\r
- cApplicationList->InsertString(0, CString(MAKEINTRESOURCE(IDS_DIALOG_TITLE)));\r
-\r
- // Add Default\r
- cApplicationList->InsertString( 0, CString(MAKEINTRESOURCE(IDS_DEFAULT_TITLE)));\r
- cApplicationList->SelectString(-1, CString(MAKEINTRESOURCE(IDS_DEFAULT_TITLE)));\r
+ AddIMEInfo(cProperties);\r
}\r
\r
-void CProfile::AddIMEInfo(CComboBox *cApplicationList)\r
+void CProfile::AddIMEInfo(CProperties& cProperties)\r
{\r
- const UINT n = GetKeyboardLayoutList(0, NULL);\r
- if (!n)\r
- return;\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
+ IMEList imeList;\r
+ for (IMEListIterator p = imeList.begin(); p != imeList.end(); ++p)\r
+ cProperties.AddItem(p->szDescription, p->szFileName);\r
}\r
\r
void CProfile::GetTaskList()\r
{\r
if (nAppID == MAX_APP)\r
return;\r
- m_Config.nSettingStyle[nAppID] = nSettingStyle;\r
+ m_Config.nSettingStyle[nAppID] = static_cast<BYTE>(nSettingStyle);\r
}\r
\r
BOOL CProfile::Is106Keyboard()\r
return keyboard == JAPANESE_KEYBOARD;\r
}\r
\r
-BOOL CProfile::IsTheString(const CString sz, const UINT nID)\r
-{\r
- return sz == CString(MAKEINTRESOURCE(nID));\r
-}\r
-\r
-// if sz is "Default", return TRUE\r
-BOOL CProfile::IsDefault(const CString sz)\r
+void CProfile::SetAppTitle(const int nAppID, const CString& appTitle)\r
{\r
- return IsTheString(sz, IDS_DEFAULT);\r
-}\r
-\r
-// if sz is "Dialog", return TRUE\r
-BOOL CProfile::IsDialog(const CString sz)\r
-{\r
- return IsTheString(sz, IDS_DIALOG);\r
-}\r
-\r
-void CProfile::GetApplicationTitle(CComboBox *const cApplicationList, CString &rList, const int nIndex)\r
-{\r
- if (0 <= nIndex) {\r
- cApplicationList->GetLBText(nIndex, rList);\r
- } else {\r
- cApplicationList->GetWindowText(rList);\r
- }\r
-\r
- if (IsTheString(rList, IDS_DEFAULT_TITLE)) {\r
- rList.LoadString(IDS_DEFAULT);\r
- }\r
-\r
- if (IsTheString(rList, IDS_DIALOG_TITLE)) {\r
- rList.LoadString(IDS_DIALOG);\r
- }\r
-\r
- return;\r
-}\r
-\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
- _tcsncpy_s(m_szAppTitle[nAppID], szApplicationTitle, _TRUNCATE);\r
- szApplicationTitle.Empty();\r
- } else { // SetDialogData\r
- CString szListItem;\r
- CProfile::GetApplicationTitle(cApplicationList, szListItem);\r
- const int nEndTitle = szListItem.ReverseFind(_T('('));\r
- if (nEndTitle > 0)\r
- szApplicationTitle = szListItem.Left(nEndTitle);\r
- }\r
+ _tcsncpy_s(m_szAppTitle[nAppID], appTitle, _TRUNCATE);\r
}\r
\r
void CProfile::SetCommandID(const int nAppID, const int nType, const int nKey, int nComID)\r
for (nComID = 1; nComID < MAX_COMMAND; ++nComID)\r
if (Commands[nComID].fCommand == CCommands::C_Eisu)\r
break;\r
- m_Config.nCommandID[nAppID][nType][nKey] = nComID;\r
+ m_Config.nCommandID[nAppID][nType][nKey] = static_cast<BYTE>(nComID);\r
}\r
\r
int CProfile::GetCommandID(const int nAppID, const int nType, const int nKey)\r
\r
void CProfile::SetKillRingMax(const int nAppID, const int nKillRingMax)\r
{\r
- m_Config.nKillRingMax[nAppID] = nKillRingMax;\r
+ m_Config.nKillRingMax[nAppID] = static_cast<BYTE>(nKillRingMax > 255 ? 255 : nKillRingMax);\r
}\r
\r
int CProfile::GetKillRingMax(const int nAppID)\r
\r
void CProfile::SetUseDialogSetting(const int nAppID, const BOOL bUseDialogSetting)\r
{\r
- m_Config.bUseDialogSetting[nAppID] = bUseDialogSetting;\r
+ m_Config.bUseDialogSetting[nAppID] = static_cast<BYTE>(bUseDialogSetting);\r
}\r
\r
BOOL CProfile::GetUseDialogSetting(const int nAppID)\r
}\r
}\r
\r
-int CProfile::GetCurrentApplicationID(CComboBox *const cApplicationList, const CString szCurrentApplication)\r
-{\r
- int nCounter = cApplicationList->GetCount();\r
- CString szListItem;\r
- int nCurSel = cApplicationList->GetCurSel();\r
-\r
- for (int i = 0; i < nCounter; ++i) {\r
- cApplicationList->SetCurSel(i);\r
- CProfile::GetApplicationTitle(cApplicationList, szListItem);\r
- if (szListItem.Find(szCurrentApplication) != -1) {\r
- cApplicationList->SetCurSel(nCurSel);\r
- return i;\r
- }\r
- }\r
- return -1;\r
-}\r
-\r
void CProfile::CopyData(const CString szDstApp, const CString szSrcApp)\r
{\r
const int nDstApp = AssignAppID(szDstApp);\r
\r
void CProfile::SetEnableCUA(const int nAppID, const BOOL bEnableCUA)\r
{\r
- m_Config.bEnableCUA[nAppID] = bEnableCUA;\r
+ m_Config.bEnableCUA[nAppID] = static_cast<BYTE>(bEnableCUA);\r
}\r
\r
int CProfile::GetKeyboardSpeed()\r