[USERINIT]

Select the current keyboard layout in the keyloard layout list.

svn path=/trunk/; revision=70745
This commit is contained in:
Eric Kohl 2016-02-14 18:57:12 +00:00
parent c95d274bf6
commit 9a468d30e5

View file

@ -302,12 +302,16 @@ CreateKeyboardLayoutList(
HWND hItemsList) HWND hItemsList)
{ {
HKEY hKey; HKEY hKey;
WCHAR szLayoutID[9], KeyName[MAX_PATH]; WCHAR szLayoutId[9], szCurrentLayoutId[9];
WCHAR KeyName[MAX_PATH];
DWORD dwIndex = 0; DWORD dwIndex = 0;
DWORD dwSize; DWORD dwSize;
INT iIndex; INT iIndex;
LONG lError; LONG lError;
ULONG ulLayoutID; ULONG ulLayoutId;
if (!GetKeyboardLayoutNameW(szCurrentLayoutId))
wcscpy(szCurrentLayoutId, L"00000409");
lError = RegOpenKeyExW(HKEY_LOCAL_MACHINE, lError = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
L"System\\CurrentControlSet\\Control\\Keyboard Layouts", L"System\\CurrentControlSet\\Control\\Keyboard Layouts",
@ -319,11 +323,11 @@ CreateKeyboardLayoutList(
while (TRUE) while (TRUE)
{ {
dwSize = sizeof(szLayoutID) / sizeof(WCHAR); dwSize = sizeof(szLayoutId) / sizeof(WCHAR);
lError = RegEnumKeyExW(hKey, lError = RegEnumKeyExW(hKey,
dwIndex, dwIndex,
szLayoutID, szLayoutId,
&dwSize, &dwSize,
NULL, NULL,
NULL, NULL,
@ -332,15 +336,14 @@ CreateKeyboardLayoutList(
if (lError != ERROR_SUCCESS) if (lError != ERROR_SUCCESS)
break; break;
GetLayoutName(szLayoutID, KeyName); GetLayoutName(szLayoutId, KeyName);
iIndex = (INT)SendMessageW(hItemsList, CB_ADDSTRING, 0, (LPARAM)KeyName); iIndex = (INT)SendMessageW(hItemsList, CB_ADDSTRING, 0, (LPARAM)KeyName);
ulLayoutID = wcstoul(szLayoutID, NULL, 16); ulLayoutId = wcstoul(szLayoutId, NULL, 16);
SendMessageW(hItemsList, CB_SETITEMDATA, iIndex, (LPARAM)ulLayoutID); SendMessageW(hItemsList, CB_SETITEMDATA, iIndex, (LPARAM)ulLayoutId);
// FIXME! if (wcscmp(szLayoutId, szCurrentLayoutId) == 0)
if (wcscmp(szLayoutID, L"00000409") == 0)
{ {
SendMessageW(hItemsList, CB_SETCURSEL, (WPARAM)iIndex, (LPARAM)0); SendMessageW(hItemsList, CB_SETCURSEL, (WPARAM)iIndex, (LPARAM)0);
} }