SelectLayoutByLang(VOID)
{
TCHAR Layout[MAX_PATH], Lang[MAX_PATH], LangID[MAX_PATH];
- INT iIndex;
- LCID Lcid;
+ INT iIndex;
+ LCID Lcid;
iIndex = SendMessage(hLangList, CB_GETCURSEL, 0, 0);
Lcid = SendMessage(hLangList, CB_GETITEMDATA, iIndex, 0);
- GetLocaleInfo(MAKELCID(Lcid, SORT_DEFAULT), LOCALE_ILANGUAGE, (WORD*)Lang, sizeof(Lang));
+ GetLocaleInfo(MAKELCID(Lcid, SORT_DEFAULT), LOCALE_ILANGUAGE, (WORD*)Lang, sizeof(Lang));
- _stprintf(LangID, _T("0000%s"), Lang);
+ _stprintf(LangID, _T("0000%s"), Lang);
- if (GetLayoutName(LangID, Layout))
- {
- SendMessage(hLayoutList, CB_SELECTSTRING,
- (WPARAM) -1, (LPARAM)Layout);
- }
+ if (GetLayoutName(LangID, Layout))
+ {
+ SendMessage(hLayoutList, CB_SELECTSTRING,
+ (WPARAM) -1, (LPARAM)Layout);
+ }
}
static VOID
AddNewLayout(HWND hwndDlg)
{
- TCHAR Lang[MAX_PATH], LangID[MAX_PATH], LayoutID[MAX_PATH];
- INT iLang, iLayout;
- LCID Lcid;
+ TCHAR Lang[MAX_PATH], LangID[MAX_PATH], LayoutID[MAX_PATH];
+ INT iLang, iLayout;
+ LCID Lcid;
- iLang = SendMessage(hLangList, CB_GETCURSEL, 0, 0);
- iLayout = SendMessage(hLayoutList, CB_GETCURSEL, 0, 0);
+ iLang = SendMessage(hLangList, CB_GETCURSEL, 0, 0);
+ iLayout = SendMessage(hLayoutList, CB_GETCURSEL, 0, 0);
- if ((iLang == CB_ERR) || (iLayout == CB_ERR)) return;
+ if ((iLang == CB_ERR) || (iLayout == CB_ERR)) return;
- Lcid = (LCID) SendMessage(hLangList, CB_GETITEMDATA, iLang, 0);
- GetLocaleInfo(MAKELCID(Lcid, SORT_DEFAULT), LOCALE_ILANGUAGE, (WORD*)Lang, sizeof(Lang));
- _stprintf(LangID, _T("0000%s"), Lang);
+ Lcid = (LCID) SendMessage(hLangList, CB_GETITEMDATA, iLang, 0);
+ GetLocaleInfo(MAKELCID(Lcid, SORT_DEFAULT), LOCALE_ILANGUAGE, (WORD*)Lang, sizeof(Lang));
+ _stprintf(LangID, _T("0000%s"), Lang);
- _tcscpy(LayoutID, (LPTSTR)SendMessage(hLayoutList, CB_GETITEMDATA, iLayout, 0));
+ _tcscpy(LayoutID, (LPTSTR)SendMessage(hLayoutList, CB_GETITEMDATA, iLayout, 0));
- if (_tcscmp(LangID, LayoutID) == 0)
- {
- MessageBox(0, L"", L"", MB_OK);
- HKEY hKey;
+ if (_tcscmp(LangID, LayoutID) == 0)
+ {
+ MessageBox(0, L"", L"", MB_OK);
+ HKEY hKey;
- if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Keyboard Layout\\Preload"), 0, KEY_WRITE, &hKey))
- {
-
- }
- }
+ if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Keyboard Layout\\Preload"), 0, KEY_WRITE, &hKey))
+ {
+
+ }
+ }
}
VOID
CreateKeyboardLayoutList(VOID)
{
- HKEY hKey, hSubKey;
- TCHAR szBuf[MAX_PATH], KeyName[MAX_PATH];
- LONG Ret;
- DWORD dwIndex = 0;
-
- if (RegOpenKey(HKEY_LOCAL_MACHINE, _T("System\\CurrentControlSet\\Control\\Keyboard Layouts"), &hKey) == ERROR_SUCCESS)
- {
- Ret = RegEnumKey(hKey, dwIndex, szBuf, sizeof(szBuf) / sizeof(TCHAR));
- if (Ret == ERROR_SUCCESS)
- {
- while (Ret == ERROR_SUCCESS)
- {
- _stprintf(KeyName, _T("System\\CurrentControlSet\\Control\\Keyboard Layouts\\%s"), szBuf);
- if (RegOpenKey(HKEY_LOCAL_MACHINE, KeyName, &hSubKey) == ERROR_SUCCESS)
- {
- DWORD Length = MAX_PATH;
-
- if (RegQueryValueEx(hSubKey, _T("Layout Text"), NULL, NULL, (LPBYTE)KeyName, &Length) == ERROR_SUCCESS)
- {
- UINT iIndex;
- iIndex = (UINT) SendMessage(hLayoutList, CB_ADDSTRING, 0, (LPARAM)KeyName);
-
- SendMessage(hLayoutList, CB_SETITEMDATA, iIndex, (LPARAM)szBuf);
-
- // FIXME!
- if (_tcscmp(szBuf, _T("00000409")) == 0)
- {
- SendMessage(hLayoutList, CB_SELECTSTRING, (WPARAM) -1, (LPARAM)KeyName);
- }
-
- dwIndex++;
- Ret = RegEnumKey(hKey, dwIndex, szBuf, sizeof(szBuf) / sizeof(TCHAR));
- }
- }
-
- RegCloseKey(hSubKey);
- }
- }
- }
-
- RegCloseKey(hKey);
+ HKEY hKey, hSubKey;
+ TCHAR szBuf[MAX_PATH], KeyName[MAX_PATH];
+ LONG Ret;
+ DWORD dwIndex = 0;
+
+ if (RegOpenKey(HKEY_LOCAL_MACHINE, _T("System\\CurrentControlSet\\Control\\Keyboard Layouts"), &hKey) == ERROR_SUCCESS)
+ {
+ Ret = RegEnumKey(hKey, dwIndex, szBuf, sizeof(szBuf) / sizeof(TCHAR));
+ if (Ret == ERROR_SUCCESS)
+ {
+ while (Ret == ERROR_SUCCESS)
+ {
+ _stprintf(KeyName, _T("System\\CurrentControlSet\\Control\\Keyboard Layouts\\%s"), szBuf);
+ if (RegOpenKey(HKEY_LOCAL_MACHINE, KeyName, &hSubKey) == ERROR_SUCCESS)
+ {
+ DWORD Length = MAX_PATH;
+
+ if (RegQueryValueEx(hSubKey, _T("Layout Text"), NULL, NULL, (LPBYTE)KeyName, &Length) == ERROR_SUCCESS)
+ {
+ UINT iIndex;
+ iIndex = (UINT) SendMessage(hLayoutList, CB_ADDSTRING, 0, (LPARAM)KeyName);
+
+ SendMessage(hLayoutList, CB_SETITEMDATA, iIndex, (LPARAM)szBuf);
+
+ // FIXME!
+ if (_tcscmp(szBuf, _T("00000409")) == 0)
+ {
+ SendMessage(hLayoutList, CB_SELECTSTRING, (WPARAM) -1, (LPARAM)KeyName);
+ }
+
+ dwIndex++;
+ Ret = RegEnumKey(hKey, dwIndex, szBuf, sizeof(szBuf) / sizeof(TCHAR));
+ }
+ }
+
+ RegCloseKey(hSubKey);
+ }
+ }
+ }
+
+ RegCloseKey(hKey);
}
/* Language enumerate procedure */
SendMessage(hLangList, CB_SETITEMDATA,
Index, (LPARAM)Lcid);
- // FIXME!
- if (Lcid == 0x0409)
- {
- SendMessage(hLangList, CB_SELECTSTRING,
+ // FIXME!
+ if (Lcid == 0x0409)
+ {
+ SendMessage(hLangList, CB_SELECTSTRING,
(WPARAM) -1, (LPARAM)Lang);
- }
+ }
return TRUE;
}
switch (message)
{
case WM_INITDIALOG:
- {
- hLangList = GetDlgItem(hDlg, IDC_INPUT_LANG_COMBO);
- hLayoutList = GetDlgItem(hDlg, IDC_KEYBOARD_LO_COMBO);
+ {
+ hLangList = GetDlgItem(hDlg, IDC_INPUT_LANG_COMBO);
+ hLayoutList = GetDlgItem(hDlg, IDC_KEYBOARD_LO_COMBO);
EnumSystemLocales(LanguagesEnumProc, LCID_INSTALLED);
CreateKeyboardLayoutList();
- }
+ }
break;
case WM_COMMAND:
- {
+ {
switch (LOWORD(wParam))
{
case IDC_INPUT_LANG_COMBO:
- {
+ {
if (HIWORD(wParam) == CBN_SELCHANGE)
{
SelectLayoutByLang();
}
- }
+ }
break;
case IDOK:
- {
- AddNewLayout(hDlg);
- EndDialog(hDlg, LOWORD(wParam));
- }
+ {
+ AddNewLayout(hDlg);
+ EndDialog(hDlg, LOWORD(wParam));
+ }
break;
case IDCANCEL:
- {
+ {
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
- }
+ }
}
- }
- break;
+ }
+ break;
}
return FALSE;
/* Applets */
APPLET Applets[NUM_APPLETS] =
{
- {IDI_CPLSYSTEM, IDS_CPLSYSTEMNAME, IDS_CPLSYSTEMDESCRIPTION, SystemApplet}
+ {IDI_CPLSYSTEM, IDS_CPLSYSTEMNAME, IDS_CPLSYSTEMDESCRIPTION, SystemApplet}
};
typedef struct
{
- LANGID LangId;
- TCHAR LangName[MAX_PATH];
- TCHAR LayoutName[MAX_PATH];
- TCHAR ValName[MAX_PATH];
- TCHAR IndName[MAX_PATH];
- TCHAR SubName[MAX_PATH];
+ LANGID LangId;
+ TCHAR LangName[MAX_PATH];
+ TCHAR LayoutName[MAX_PATH];
+ TCHAR ValName[MAX_PATH];
+ TCHAR IndName[MAX_PATH];
+ TCHAR SubName[MAX_PATH];
} LAYOUT_ITEM, *LPLAYOUT_ITEM;
BOOL
{
LV_COLUMN column;
TCHAR szBuf[MAX_PATH];
- HWND hList = GetDlgItem(hWnd, IDC_KEYLAYOUT_LIST);
+ HWND hList = GetDlgItem(hWnd, IDC_KEYLAYOUT_LIST);
ZeroMemory(&column, sizeof(LV_COLUMN));
column.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
column.cx = 160;
(VOID) ListView_InsertColumn(hList, 1, &column);
- column.fmt = LVCFMT_RIGHT;
+ column.fmt = LVCFMT_RIGHT;
column.cx = 145;
column.iSubItem = 2;
LoadString(hApplet, IDS_LAYOUT, szBuf, sizeof(szBuf) / sizeof(TCHAR));
static BOOL
InitLangList(HWND hWnd)
{
- HKEY hKey, hSubKey;
- TCHAR szBuf[MAX_PATH], szPreload[MAX_PATH], szSub[MAX_PATH];
- LAYOUT_ITEM lItem;
- AddListColumn(hWnd);
- LONG Ret;
- DWORD dwIndex = 0, dwType, dwSize;
- LV_ITEM item;
- HWND hList = GetDlgItem(hWnd, IDC_KEYLAYOUT_LIST);
-
- (VOID) ListView_SetExtendedListViewStyle(hList, LVS_EX_FULLROWSELECT);
-
+ HKEY hKey, hSubKey;
+ TCHAR szBuf[MAX_PATH], szPreload[MAX_PATH], szSub[MAX_PATH];
+ LAYOUT_ITEM lItem;
+ AddListColumn(hWnd);
+ LONG Ret;
+ DWORD dwIndex = 0, dwType, dwSize;
+ LV_ITEM item;
+ HWND hList = GetDlgItem(hWnd, IDC_KEYLAYOUT_LIST);
+
+ (VOID) ListView_SetExtendedListViewStyle(hList, LVS_EX_FULLROWSELECT);
+
if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Keyboard Layout\\Preload"),
- 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS)
+ 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS)
{
- dwSize = MAX_PATH;
- Ret = RegEnumValue(hKey, dwIndex, szBuf, &dwSize, NULL, &dwType, NULL, NULL);
- if (Ret == ERROR_SUCCESS)
- {
- while (Ret == ERROR_SUCCESS)
- {
- _tcscpy(lItem.ValName, szBuf);
-
- dwSize = MAX_PATH;
- RegQueryValueEx(hKey, szBuf, NULL, NULL, (LPBYTE)szPreload, &dwSize);
-
- lItem.LangId = _tcstoul(szPreload, NULL, 16);
-
- GetLocaleInfo(lItem.LangId, LOCALE_SISO639LANGNAME, (LPTSTR) szBuf, sizeof(szBuf));
- _tcscpy(lItem.IndName, _tcsupr(szBuf));
-
- GetLocaleInfo(lItem.LangId, LOCALE_SLANGUAGE, (LPTSTR)szBuf, sizeof(szBuf));
- _tcscpy(lItem.LangName, szBuf);
-
- if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Keyboard Layout\\Substitutes"),
- 0, KEY_QUERY_VALUE, &hSubKey) == ERROR_SUCCESS)
- {
- dwSize = MAX_PATH;
- if (RegQueryValueEx(hSubKey, szPreload, NULL, NULL, (LPBYTE)szSub, &dwSize) == ERROR_SUCCESS)
- {
- _tcscpy(lItem.SubName, szPreload);
- if (GetLayoutName(szSub, szBuf))
- {
- _tcscpy(lItem.LayoutName, szBuf);
- }
- }
- else
- {
- _tcscpy(lItem.SubName, _T(""));
- }
- }
-
- if (_tcslen(lItem.SubName) < 2)
- {
- if (GetLayoutName(szPreload, szBuf))
- {
- _tcscpy(lItem.LayoutName, szBuf);
- }
- }
-
- ZeroMemory(&item, sizeof(LV_ITEM));
- item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE;
- item.pszText = lItem.IndName;
- item.lParam = (LPARAM)&lItem;
- item.iItem = (INT) dwIndex;
- INT i = ListView_InsertItem(hList, &item);
-
- ListView_SetItemText(hList, i, 1, lItem.LangName);
- ListView_SetItemText(hList, i, 2, lItem.LayoutName);
-
- dwIndex++;
- Ret = RegEnumValue(hKey, dwIndex, szBuf, &dwSize, NULL, &dwType, NULL, NULL);
- RegCloseKey(hSubKey);
-
- if (_tcscmp(lItem.ValName, _T("1")) == 0)
- {
- (VOID) ListView_SetHotItem(hList, i);
- }
- }
- }
- }
-
- RegCloseKey(hKey);
+ dwSize = MAX_PATH;
+ Ret = RegEnumValue(hKey, dwIndex, szBuf, &dwSize, NULL, &dwType, NULL, NULL);
+ if (Ret == ERROR_SUCCESS)
+ {
+ while (Ret == ERROR_SUCCESS)
+ {
+ _tcscpy(lItem.ValName, szBuf);
+
+ dwSize = MAX_PATH;
+ RegQueryValueEx(hKey, szBuf, NULL, NULL, (LPBYTE)szPreload, &dwSize);
+
+ lItem.LangId = _tcstoul(szPreload, NULL, 16);
+
+ GetLocaleInfo(lItem.LangId, LOCALE_SISO639LANGNAME, (LPTSTR) szBuf, sizeof(szBuf));
+ _tcscpy(lItem.IndName, _tcsupr(szBuf));
+
+ GetLocaleInfo(lItem.LangId, LOCALE_SLANGUAGE, (LPTSTR)szBuf, sizeof(szBuf));
+ _tcscpy(lItem.LangName, szBuf);
+
+ if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Keyboard Layout\\Substitutes"),
+ 0, KEY_QUERY_VALUE, &hSubKey) == ERROR_SUCCESS)
+ {
+ dwSize = MAX_PATH;
+ if (RegQueryValueEx(hSubKey, szPreload, NULL, NULL, (LPBYTE)szSub, &dwSize) == ERROR_SUCCESS)
+ {
+ _tcscpy(lItem.SubName, szPreload);
+ if (GetLayoutName(szSub, szBuf))
+ {
+ _tcscpy(lItem.LayoutName, szBuf);
+ }
+ }
+ else
+ {
+ _tcscpy(lItem.SubName, _T(""));
+ }
+ }
+
+ if (_tcslen(lItem.SubName) < 2)
+ {
+ if (GetLayoutName(szPreload, szBuf))
+ {
+ _tcscpy(lItem.LayoutName, szBuf);
+ }
+ }
+
+ ZeroMemory(&item, sizeof(LV_ITEM));
+ item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE;
+ item.pszText = lItem.IndName;
+ item.lParam = (LPARAM)&lItem;
+ item.iItem = (INT) dwIndex;
+ INT i = ListView_InsertItem(hList, &item);
+
+ ListView_SetItemText(hList, i, 1, lItem.LangName);
+ ListView_SetItemText(hList, i, 2, lItem.LayoutName);
+
+ dwIndex++;
+ Ret = RegEnumValue(hKey, dwIndex, szBuf, &dwSize, NULL, &dwType, NULL, NULL);
+ RegCloseKey(hSubKey);
+
+ if (_tcscmp(lItem.ValName, _T("1")) == 0)
+ {
+ (VOID) ListView_SetHotItem(hList, i);
+ }
+ }
+ }
+ }
+
+ RegCloseKey(hKey);
return TRUE;
}