and CProperties.
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
// 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
\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
}\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, appTitle, 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
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
+ TCHAR szFileName[MAX_PATH], 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
+ ImmGetIMEFileName(*p, szFileName, MAX_PATH))\r
+ cProperties.AddItem(szDescription, szFileName);\r
}\r
\r
void CProfile::GetTaskList()\r
return keyboard == JAPANESE_KEYBOARD;\r
}\r
\r
-BOOL CProfile::IsTheString(const CString sz, const UINT nID)\r
+void CProfile::SetAppTitle(const int nAppID, const CString& appTitle)\r
{\r
- return sz == CString(MAKEINTRESOURCE(nID));\r
-}\r
-\r
-// if sz is "Default", return TRUE\r
-BOOL CProfile::IsDefault(const CString sz)\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
}\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
#include <winperf.h> // for Windows NT\r
#include "resource.h"\r
+#include "properties.h"\r
\r
struct TASK_LIST {\r
DWORD dwProcessId;\r
static void SaveScanCodeMap(HKEY_TYPE hkeyType);\r
static void LoadScanCodeMap(HKEY_TYPE hkeyType);\r
static BOOL Is106Keyboard();\r
- static BOOL IsDialog(CString sz);\r
static BOOL GetUseDialogSetting(int nAppID);\r
static void SetUseDialogSetting(int nAppID, BOOL bUseDialogSetting);\r
static int GetAppID(const LPCSTR szAppName);\r
static void ReadKeyBind(int& pnCommandType, int& pnKey, LPCTSTR szKeyBind);\r
static LPCTSTR Key2String(int nKey);\r
static LPCTSTR CommandType2String(int nType);\r
- static int GetCurrentApplicationID(CComboBox *cApplicationList, CString szCurrentApplication);\r
static int GetKillRingMax(int nAppID);\r
static void SetKillRingMax(int nAppID, int nKillRingMax);\r
static int GetCommandID(int nAppID, int nType, int nKey);\r
static void SetCommandID(int nAppID, int nType, int nKey, int nComID);\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 void SetAppTitle(const int nAppID, const CString& appTitle);\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 void InitAppList(CProperties& cProperties);\r
static int GetSavedSettingCount();\r
static void ClearData(CString szCurrentApplication);\r
static void InitDllData();\r
static void SaveKeyBind(const LPCSTR szAppName, int nComID, int nType, int nKey);\r
static void AddKeyBind2C_(const LPCSTR szApplicationName, BYTE bVk);\r
static void LevelUp();\r
- static void Item2AppName(CString *sz);\r
- static int IsNotSameString(CComboBox *pApplication, CString szListItem);\r
static bool GetAppTitle(CString& appTitle, const CString& windowName, int nth = 1000);\r
static BOOL CALLBACK EnumWindowsProc(HWND hWnd, LPARAM lParam);\r
- static BOOL IsTheString(CString sz, UINT nID);\r
static void SetDllData();\r
static CONFIG m_Config;\r
static TCHAR m_szAppTitle[MAX_APP][WINDOW_TEXT_LENGTH];\r
static CString WriteKeyBind(int nType, int nKey);\r
static void LoadRegistry();\r
static void SaveRegistry();\r
- static void AddIMEInfo(CComboBox *cApplicationList);\r
+ static void AddIMEInfo(CProperties& cProperties);\r
};\r
\r
#endif // !defined(AFX_PROFILE_H__9415254D_4656_484B_A730_E02580D8A221__INCLUDED_)\r
DDX_Control(pDX, IDC_SELECT_ALL, m_cSelectAll);\r
DDX_Control(pDX, IDC_CLEAR_ALL, m_cClearAll);\r
DDX_Control(pDX, IDC_LOAD_DEFAULT, m_cLoadDefault);\r
- DDX_Control(pDX, IDC_APPLICATION, m_cApplication);\r
+ DDX_Control(pDX, IDC_APPLICATION, m_cAppList);\r
DDX_Radio(pDX, IDC_SETTING_DEFAULT, m_nSettingStyle);\r
DDX_Text(pDX, IDC_KILL_RING_MAX, m_nKillRingMax);\r
DDV_MinMaxInt(pDX, m_nKillRingMax, 0, 2147483647);\r
ScreenToClient(&rcSheet);\r
m_sheet.SetWindowPos(NULL, rcSheet.left - 11, rcSheet.top - 8, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE);\r
\r
-\r
SetForegroundWindow();\r
\r
- InitApplicationList();\r
+ InitAppList();\r
\r
CProfile::LoadData();\r
m_appName.LoadString(IDS_DEFAULT);\r
\r
void CProperties::OnDropdownApplication() \r
{\r
- InitApplicationList();\r
-\r
- int nID = GetCurrentApplicationID();\r
- if (nID != CB_ERR) {\r
- m_cApplication.SetCurSel(nID);\r
- } else {\r
- GetDialogData();\r
- m_appName.LoadString(IDS_DEFAULT_TITLE);\r
- m_cApplication.SelectString(-1, m_appName);\r
+ InitAppList();\r
+ int i;\r
+ for (i = 0; i < m_cAppList.GetCount(); ++i) {\r
+ CString appTitle, appName;\r
+ GetAppTitleAndName(i, appTitle, appName);\r
+ if (m_appName == appName)\r
+ m_cAppList.SetCurSel(i);\r
+ }\r
+ if (i == m_cAppList.GetCount()) {\r
+ m_appTitle.LoadString(IDS_DEFAULT_TITLE);\r
+ m_cAppList.SelectString(-1, m_appTitle);\r
SetDialogData();\r
}\r
}\r
\r
void CProperties::OnSelchangeApplication() \r
{\r
- GetDialogData();\r
-\r
- CProfile::GetApplicationTitle(&m_cApplication, m_appName, m_cApplication.GetCurSel());\r
- int nStart;\r
- if ((nStart = m_appName.ReverseFind(_T('('))) != -1) {\r
- ++nStart;\r
- m_appName =\r
- m_appName.Mid(nStart, m_appName.GetLength() - nStart - 1);\r
- }\r
-\r
+ GetAppTitleAndName(m_cAppList.GetCurSel(), m_appTitle, m_appName);\r
SetDialogData();\r
EnableControl(ACTIVE_TAB);\r
}\r
\r
-void CProperties::InitApplicationList()\r
+void CProperties::InitAppList()\r
{\r
- CProfile::InitApplicationList(&m_cApplication);\r
-}\r
-\r
-int CProperties::GetCurrentApplicationID()\r
-{\r
- return CProfile::GetCurrentApplicationID(&m_cApplication, m_appName);\r
+ m_cAppList.ResetContent();\r
+ CProfile::InitAppList(*this);\r
+ // Add Dialog\r
+ m_cAppList.InsertString(0, CString(MAKEINTRESOURCE(IDS_DIALOG_TITLE)));\r
+ // Add Default\r
+ m_cAppList.InsertString( 0, CString(MAKEINTRESOURCE(IDS_DEFAULT_TITLE)));\r
+ m_cAppList.SelectString(-1, CString(MAKEINTRESOURCE(IDS_DEFAULT_TITLE)));\r
}\r
\r
void CProperties::GetDialogData()\r
}\r
m_nAppID = CProfile::AssignAppID(m_appName);\r
CProfile::SetSettingStyle(m_nAppID, m_nSettingStyle);\r
- CProfile::UpdateApplicationTitle(&m_cApplication, m_appName, m_nAppID, TRUE);\r
+ CProfile::SetAppTitle(m_nAppID, m_appTitle);\r
CProfile::SetKillRingMax(m_nAppID, m_nKillRingMax);\r
CProfile::SetUseDialogSetting(m_nAppID, m_cUseDialogSetting.GetCheck() == BST_CHECKED);\r
CString szWindowText;\r
m_nSettingStyle = CProfile::GetSettingStyle(m_nAppID);\r
if (m_nAppID == MAX_APP)\r
m_nAppID = CProfile::DefaultAppID(); // fall back to the default\r
- EnableUseDefaultButton(!CProfile::IsDefault(m_appName) && !CProfile::IsDialog(m_appName));\r
- CProfile::UpdateApplicationTitle(&m_cApplication, m_appName, m_nAppID, FALSE);\r
+ EnableUseDefaultButton(m_appName != CString(MAKEINTRESOURCE(IDS_DEFAULT)) &&\r
+ m_appName != CString(MAKEINTRESOURCE(IDS_DIALOG)));\r
m_nKillRingMax = CProfile::GetKillRingMax(m_nAppID);\r
m_cUseDialogSetting.SetCheck(CProfile::GetUseDialogSetting(m_nAppID) ? BST_CHECKED : BST_UNCHECKED);\r
m_cWindowText.SetWindowText(CProfile::GetWindowText(m_nAppID));\r
m_list.SetDialogData();\r
}\r
\r
+void CProperties::AddItem(const CString& appTitle, const CString& appName)\r
+{\r
+ for (int i = 0; i < m_cAppList.GetCount(); ++i) {\r
+ CString tmpTitle, tmpName;\r
+ GetAppTitleAndName(i, tmpTitle, tmpName);\r
+ if (appName == tmpName)\r
+ return;\r
+ }\r
+ CString item;\r
+ item.Format(IDS_APPLICATION_LIST_ITEM, appTitle, appName);\r
+ m_cAppList.AddString(item);\r
+}\r
+\r
+void CProperties::GetAppTitleAndName(const int nSel, CString& appTitle, CString& appName)\r
+{\r
+ appTitle.Empty();\r
+ appName.Empty();\r
+ CString item;\r
+ if (nSel < 0)\r
+ m_cAppList.GetWindowText(item);\r
+ else\r
+ m_cAppList.GetLBText(nSel, item);\r
+\r
+ if (item == CString(MAKEINTRESOURCE(IDS_DEFAULT_TITLE))) {\r
+ appName.LoadString(IDS_DEFAULT);\r
+ return;\r
+ }\r
+ if (item == CString(MAKEINTRESOURCE(IDS_DIALOG_TITLE))) {\r
+ appName.LoadString(IDS_DIALOG);\r
+ return;\r
+ }\r
+ int nParen = item.ReverseFind(_T('('));\r
+ if (nParen < 0)\r
+ return;\r
+ appTitle = item.Left(nParen);\r
+ appName = item.Mid(nParen + 1, item.GetLength() - nParen -2);\r
+}\r
+\r
void CProperties::EnableControl(TAB_NAME tab)\r
{\r
if (tab & ACTIVE_TAB) {\r
void CProperties::EnableUseDialogSettingButton(BOOL bEnable)\r
{\r
m_cUseDialogSetting.EnableWindow(bEnable);\r
- if (CProfile::IsDialog(m_appName)) {\r
+ if (m_appName == CString(MAKEINTRESOURCE(IDS_DIALOG)))\r
m_cUseDialogSetting.EnableWindow(FALSE);\r
- }\r
}\r
\r
void CProperties::EnableLoadDefaultButton(BOOL bEnable)\r
{\r
m_cLoadDefault.EnableWindow(bEnable);\r
- if (CProfile::IsDefault(m_appName)) {\r
+ if (m_appName == CString(MAKEINTRESOURCE(IDS_DEFAULT)))\r
m_cLoadDefault.EnableWindow(FALSE);\r
- }\r
}\r
\r
void CProperties::EnableUseDefaultButton(BOOL bEnable)\r
CButton m_cSelectAll;\r
CButton m_cClearAll;\r
CButton m_cLoadDefault;\r
- CComboBox m_cApplication;\r
+ CComboBox m_cAppList;\r
int m_nSettingStyle;\r
int m_nKillRingMax;\r
//}}AFX_DATA\r
CString GetCurrentApplication();\r
int GetApplicationID();\r
void EnableControl(TAB_NAME tab = BASIC_TAB);\r
+ void AddItem(const CString& appTitle, const CString& appName);\r
protected:\r
// Generated message map functions\r
//{{AFX_MSG(CProperties)\r
CPropertiesAdvanced m_advanced;\r
CPropertiesBasic m_basic;\r
CPropertySheet m_sheet;\r
+ CString m_appTitle;\r
CString m_appName;\r
void EnableLoadDefaultButton(BOOL bEnable);\r
void EnableUseDefaultButton(BOOL bEnable);\r
void EnableUseDialogSettingButton(BOOL bEnable);\r
- int GetCurrentApplicationID();\r
void GetDialogData();\r
- void InitApplicationList();\r
+ void InitAppList();\r
void SetDialogData();\r
+ void GetAppTitleAndName(const int nSel, CString& appTitle, CString& appName);\r
};\r
\r
//{{AFX_INSERT_LOCATION}}\r