- Implement "Add keyboard layout" dialog

- Other small changes

svn path=/trunk/; revision=33048
This commit is contained in:
Dmitry Chapyshev 2008-04-20 07:34:59 +00:00
parent 8b2204b25c
commit 0a8d3f23bc
6 changed files with 100 additions and 102 deletions

View file

@ -4,6 +4,7 @@
* FILE: dll/win32/input/add.c
* PURPOSE: input.dll
* PROGRAMMER: Dmitry Chapyshev (dmitry@reactos.org)
* Colin Finck
* UPDATE HISTORY:
* 06-09-2007 Created
*/
@ -38,73 +39,77 @@ SelectLayoutByLang(VOID)
static VOID
AddNewLayout(HWND hwndDlg)
{
TCHAR Lang[MAX_PATH], LangID[MAX_PATH], LayoutID[MAX_PATH];
INT iLang, iLayout;
LCID Lcid;
TCHAR NewLayout[3];
INT iLayout;
HKEY hKey;
DWORD cValues;
PTSTR pts;
iLang = SendMessage(hLangList, CB_GETCURSEL, 0, 0);
iLayout = SendMessage(hLayoutList, CB_GETCURSEL, 0, 0);
iLayout = SendMessage(hLayoutList, CB_GETCURSEL, 0, 0);
if (iLayout == CB_ERR) return;
if ((iLang == CB_ERR) || (iLayout == CB_ERR)) return;
if (RegOpenKey(HKEY_CURRENT_USER, _T("Keyboard Layout\\Preload"), &hKey) == ERROR_SUCCESS)
{
if (RegQueryInfoKey(hKey, NULL, NULL, NULL, NULL, NULL, NULL, &cValues, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
{
_stprintf(NewLayout, _T("%d"), cValues + 1);
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);
pts = (PTSTR) 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 (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Keyboard Layout\\Preload"), 0, KEY_WRITE, &hKey))
{
}
}
if (RegSetValueEx(hKey,
NewLayout,
0,
REG_SZ,
(LPBYTE)pts,
(DWORD)(_tcslen(pts)*sizeof(PTSTR))) == ERROR_SUCCESS)
{
UpdateLayoutsList();
}
}
}
}
VOID
CreateKeyboardLayoutList(VOID)
{
HKEY hKey, hSubKey;
TCHAR szBuf[MAX_PATH], KeyName[MAX_PATH];
PTSTR pstrBuf;
TCHAR szBuf[CCH_LAYOUT_ID + 1], 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)
{
while (Ret == ERROR_SUCCESS)
_stprintf(KeyName, _T("System\\CurrentControlSet\\Control\\Keyboard Layouts\\%s"), szBuf);
if (RegOpenKey(HKEY_LOCAL_MACHINE, KeyName, &hSubKey) == 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)
{
DWORD Length = MAX_PATH;
INT iIndex = (INT) SendMessage(hLayoutList, CB_ADDSTRING, 0, (LPARAM)KeyName);
if (RegQueryValueEx(hSubKey, _T("Layout Text"), NULL, NULL, (LPBYTE)KeyName, &Length) == ERROR_SUCCESS)
pstrBuf = (PTSTR)HeapAlloc(hProcessHeap, 0, (CCH_LAYOUT_ID + 1) * sizeof(TCHAR));
_tcscpy(pstrBuf, szBuf);
SendMessage(hLayoutList, CB_SETITEMDATA, iIndex, (LPARAM)pstrBuf);
// FIXME!
if (_tcscmp(szBuf, _T("00000409")) == 0)
{
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));
SendMessage(hLayoutList, CB_SETCURSEL, (WPARAM)iIndex, (LPARAM)0);
}
}
RegCloseKey(hSubKey);
dwIndex++;
Ret = RegEnumKey(hKey, dwIndex, szBuf, sizeof(szBuf) / sizeof(TCHAR));
}
}
RegCloseKey(hSubKey);
}
}
@ -180,11 +185,19 @@ AddDlgProc(HWND hDlg,
case IDCANCEL:
{
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
}
}
break;
case WM_DESTROY:
{
INT iCount;
for(iCount = SendMessage(hLayoutList, CB_GETCOUNT, 0, 0); --iCount >= 0;)
HeapFree(hProcessHeap, 0, (LPVOID)SendMessage(hLayoutList, CB_GETITEMDATA, iCount, 0));
}
break;
}
return FALSE;

View file

@ -1,27 +1,10 @@
/*
* ReactOS
* Copyright (C) 2007 ReactOS Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
*
* PROJECT: input.dll
* FILE: dll/win32/input/input.c
* PURPOSE: input.dll
* PROGRAMMER: Dmitry Chapyshev (lentind@yandex.ru)
* Colin Finck
* UPDATE HISTORY:
* 06-09-2007 Created
*/
@ -33,6 +16,7 @@
LONG CALLBACK SystemApplet(VOID);
HINSTANCE hApplet = 0;
HANDLE hProcessHeap;
/* Applets */
APPLET Applets[NUM_APPLETS] =
@ -127,6 +111,7 @@ DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpvReserved)
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
hApplet = hinstDLL;
hProcessHeap = GetProcessHeap();
break;
}

View file

@ -22,6 +22,10 @@ typedef struct
} APPLET, *PAPPLET;
extern HINSTANCE hApplet;
extern HANDLE hProcessHeap;
// Character Count of a layout ID like "00000409"
#define CCH_LAYOUT_ID 8
/* input.c */
VOID
@ -32,6 +36,8 @@ INT_PTR CALLBACK
SettingPageProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam);
BOOL
GetLayoutName(LPCTSTR lcid, LPTSTR name);
VOID
UpdateLayoutsList(VOID);
/* keysettings.c */
INT_PTR CALLBACK

View file

@ -1,27 +1,10 @@
/*
* ReactOS
* Copyright (C) 2007 ReactOS Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
*
* PROJECT: input.dll
* FILE: dll/win32/input/inputlangprop.c
* PURPOSE: input.dll
* PROGRAMMER: Dmitry Chapyshev (lentind@yandex.ru)
* Colin Finck
* UPDATE HISTORY:
* 06-09-2007 Created
*/

View file

@ -1,27 +1,10 @@
/*
* ReactOS
* Copyright (C) 2007 ReactOS Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
*
* PROJECT: input.dll
* FILE: dll/win32/input/keysettings.c
* PURPOSE: input.dll
* PROGRAMMER: Dmitry Chapyshev (lentind@yandex.ru)
* Colin Finck
* UPDATE HISTORY:
* 06-09-2007 Created
*/

View file

@ -4,6 +4,7 @@
* FILE: dll/win32/input/settings.c
* PURPOSE: input.dll
* PROGRAMMER: Dmitry Chapyshev (dmitry@reactos.org)
* Colin Finck
* UPDATE HISTORY:
* 06-09-2007 Created
*/
@ -13,6 +14,8 @@
#define BUFSIZE 256
static HWND MainDlgWnd;
typedef struct
{
LANGID LangId;
@ -81,13 +84,11 @@ 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);
INT i;
if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Keyboard Layout\\Preload"),
0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS)
@ -142,7 +143,7 @@ InitLangList(HWND hWnd)
item.pszText = lItem.IndName;
item.lParam = (LPARAM)&lItem;
item.iItem = (INT) dwIndex;
INT i = ListView_InsertItem(hList, &item);
i = ListView_InsertItem(hList, &item);
ListView_SetItemText(hList, i, 1, lItem.LangName);
ListView_SetItemText(hList, i, 2, lItem.LayoutName);
@ -163,6 +164,25 @@ InitLangList(HWND hWnd)
return TRUE;
}
VOID
UpdateLayoutsList(VOID)
{
(VOID) ListView_DeleteAllItems(GetDlgItem(MainDlgWnd, IDC_KEYLAYOUT_LIST));
InitLangList(MainDlgWnd);
}
static VOID
DeleteLayout(VOID)
{
INT iIndex;
iIndex = (INT) SendMessage(GetDlgItem(MainDlgWnd, IDC_KEYLAYOUT_LIST), LVM_GETNEXTITEM, -1, LVNI_FOCUSED);
if (iIndex != -1)
{
MessageBox(0, _T("Not implemented!"), NULL, MB_OK);
}
}
/* Property page dialog callback */
INT_PTR CALLBACK
SettingPageProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam)
@ -173,6 +193,10 @@ SettingPageProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
case WM_INITDIALOG:
{
MainDlgWnd = hwndDlg;
AddListColumn(hwndDlg);
(VOID) ListView_SetExtendedListViewStyle(GetDlgItem(MainDlgWnd, IDC_KEYLAYOUT_LIST),
LVS_EX_FULLROWSELECT);
InitLangList(hwndDlg);
EnableWindow(GetDlgItem(hwndDlg, IDC_PROP_BUTTON),FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_SET_DEFAULT),FALSE);
@ -189,6 +213,10 @@ SettingPageProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam)
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDC_REMOVE_BUTTON:
DeleteLayout();
break;
case IDC_KEY_SET_BTN:
DialogBox(hApplet,
MAKEINTRESOURCE(IDD_KEYSETTINGS),