CloseHandle(hProcessSnap);\r
}\r
\r
-// return application index\r
-// and update setting style\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
+int CProfile::DefaultAppID()\r
{\r
- if (!bSaveAndValidate) // SetDialogData\r
- *nSettingStyle = SETTING_UNDEFINED;\r
- int nAppID = GetAppID(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
- 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
- if (nAppID == MAX_APP)\r
- return nAppID;\r
+ const CString name(MAKEINTRESOURCE(IDS_DEFAULT));\r
+ for(int nAppID = 0; nAppID < MAX_APP; ++nAppID)\r
+ if (name == m_Config.szSpecialApp[nAppID])\r
+ return nAppID;\r
+ return MAX_APP;\r
+}\r
+\r
+int CProfile::AssignAppID(const LPCSTR szAppName)\r
+{\r
+ int nAppID = GetAppID(szAppName);\r
+ if (nAppID != MAX_APP)\r
+ return nAppID;\r
+ for (nAppID = 0; nAppID < MAX_APP; ++nAppID)\r
+ if (!m_Config.szSpecialApp[nAppID][0]) {\r
+ _tcsncpy_s(m_Config.szSpecialApp[nAppID], szAppName, _TRUNCATE);\r
+ return nAppID;\r
}\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
return nAppID;\r
}\r
\r
+int CProfile::GetSettingStyle(const int nAppID)\r
+{\r
+ if (nAppID == MAX_APP)\r
+ return SETTING_DEFAULT;\r
+ return m_Config.nSettingStyle[nAppID];\r
+}\r
+\r
+void CProfile::SetSettingStyle(int nAppID, int nSettingStyle)\r
+{\r
+ if (nAppID == MAX_APP)\r
+ return;\r
+ m_Config.nSettingStyle[nAppID] = nSettingStyle;\r
+}\r
+\r
BOOL CProfile::Is106Keyboard()\r
{\r
static KEYBOARD_TYPE keyboard = UNKNOWN_KEYBOARD;\r
\r
void CProfile::CopyData(const CString szDstApp, const CString szSrcApp)\r
{\r
- int nSettingStyle = SETTING_SPECIFIC;\r
- const int nDstApp = GetApplicationIndex(szDstApp, TRUE, &nSettingStyle);\r
+ const int nDstApp = AssignAppID(szDstApp);\r
const int nSrcApp = GetAppID(szSrcApp);\r
+ if (nDstApp == MAX_APP || nSrcApp == MAX_APP)\r
+ return;\r
+ SetSettingStyle(nDstApp, SETTING_SPECIFIC);\r
\r
#define CopyMember(member) CopyMemory(&m_Config. ## member ## [nDstApp], &m_Config. ## member ## [nSrcApp], sizeof(m_Config. ## member ## [nSrcApp]))\r
CopyMember(b326Compatible);\r
static void UpdateApplicationTitle(CComboBox *cApplicationList, CString szCurrentApplication, int nAppID, BOOL bSaveAndValidate);\r
static void GetApplicationTitle(CComboBox *cApplicationList, CString &rList, int nIndex = -1);\r
static BOOL IsDefault(CString sz);\r
- static int GetApplicationIndex(CString szApplicationName, BOOL bSaveAndValidate, int *nSettingStyle);\r
+ static int DefaultAppID();\r
+ static int AssignAppID(const LPCSTR szAppName);\r
+ static int GetSettingStyle(const int nAppID);\r
+ static void SetSettingStyle(const int nAppID, const int nSettingStyle);\r
static void InitApplicationList(CComboBox *cApplicationList);\r
static int GetSavedSettingCount();\r
static void ClearData(CString szCurrentApplication);\r
CProfile::ClearData(m_szCurrentApplication);\r
return;\r
}\r
- m_nApplicationID = CProfile::GetApplicationIndex(m_szCurrentApplication, TRUE, &m_nSettingStyle);\r
+ m_nApplicationID = CProfile::AssignAppID(m_szCurrentApplication);\r
+ CProfile::SetSettingStyle(m_nApplicationID, m_nSettingStyle);\r
CProfile::UpdateApplicationTitle(&m_cApplication, m_szCurrentApplication, m_nApplicationID, TRUE);\r
CProfile::SetKillRingMax(m_nApplicationID, m_nKillRingMax);\r
CProfile::SetUseDialogSetting(m_nApplicationID, m_cUseDialogSetting.GetCheck() == BST_CHECKED);\r
\r
void CProperties::SetDialogData()\r
{\r
- m_nApplicationID = CProfile::GetApplicationIndex(m_szCurrentApplication, FALSE, &m_nSettingStyle);\r
+ m_nApplicationID = CProfile::GetAppID(m_szCurrentApplication);\r
+ m_nSettingStyle = CProfile::GetSettingStyle(m_nApplicationID);\r
+ if (m_nApplicationID == MAX_APP)\r
+ m_nApplicationID = CProfile::DefaultAppID(); // fall back to the default\r
EnableUseDefaultButton(!CProfile::IsDefault(m_szCurrentApplication) && !CProfile::IsDialog(m_szCurrentApplication));\r
CProfile::UpdateApplicationTitle(&m_cApplication, m_szCurrentApplication, m_nApplicationID, FALSE);\r
m_nKillRingMax = CProfile::GetKillRingMax(m_nApplicationID);\r