Author: dchapyshev
Date: Sun Apr 20 02:34:59 2008
New Revision: 33048
URL:
http://svn.reactos.org/svn/reactos?rev=33048&view=rev
Log:
- Implement "Add keyboard layout" dialog
- Other small changes
Modified:
trunk/reactos/dll/cpl/input/add.c
trunk/reactos/dll/cpl/input/input.c
trunk/reactos/dll/cpl/input/input.h
trunk/reactos/dll/cpl/input/inputlangprop.c
trunk/reactos/dll/cpl/input/keysettings.c
trunk/reactos/dll/cpl/input/settings.c
Modified: trunk/reactos/dll/cpl/input/add.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/input/add.c?rev=33…
==============================================================================
--- trunk/reactos/dll/cpl/input/add.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/input/add.c [iso-8859-1] Sun Apr 20 02:34:59 2008
@@ -4,6 +4,7 @@
* FILE: dll/win32/input/add.c
* PURPOSE: input.dll
* PROGRAMMER: Dmitry Chapyshev (dmitry(a)reactos.org)
+ * Colin Finck
* UPDATE HISTORY:
* 06-09-2007 Created
*/
@@ -38,73 +39,77 @@
static VOID
AddNewLayout(HWND hwndDlg)
{
- 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);
-
- 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);
-
- _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))
- {
-
- }
- }
+ TCHAR NewLayout[3];
+ INT iLayout;
+ HKEY hKey;
+ DWORD cValues;
+ PTSTR pts;
+
+ iLayout = SendMessage(hLayoutList, CB_GETCURSEL, 0, 0);
+ if (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);
+
+ pts = (PTSTR) SendMessage(hLayoutList, CB_GETITEMDATA, iLayout, 0);
+
+ 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;
+
+ if (RegQueryValueEx(hSubKey, _T("Layout Text"), NULL, NULL,
(LPBYTE)KeyName, &Length) == ERROR_SUCCESS)
+ {
+ INT iIndex = (INT) SendMessage(hLayoutList, CB_ADDSTRING, 0,
(LPARAM)KeyName);
+
+ 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 @@
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;
Modified: trunk/reactos/dll/cpl/input/input.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/input/input.c?rev=…
==============================================================================
--- trunk/reactos/dll/cpl/input/input.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/input/input.c [iso-8859-1] Sun Apr 20 02:34:59 2008
@@ -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(a)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 @@
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
hApplet = hinstDLL;
+ hProcessHeap = GetProcessHeap();
break;
}
Modified: trunk/reactos/dll/cpl/input/input.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/input/input.h?rev=…
==============================================================================
--- trunk/reactos/dll/cpl/input/input.h [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/input/input.h [iso-8859-1] Sun Apr 20 02:34:59 2008
@@ -22,6 +22,10 @@
} 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 @@
SettingPageProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam);
BOOL
GetLayoutName(LPCTSTR lcid, LPTSTR name);
+VOID
+UpdateLayoutsList(VOID);
/* keysettings.c */
INT_PTR CALLBACK
Modified: trunk/reactos/dll/cpl/input/inputlangprop.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/input/inputlangpro…
==============================================================================
--- trunk/reactos/dll/cpl/input/inputlangprop.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/input/inputlangprop.c [iso-8859-1] Sun Apr 20 02:34:59 2008
@@ -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(a)yandex.ru)
+ * Colin Finck
* UPDATE HISTORY:
* 06-09-2007 Created
*/
Modified: trunk/reactos/dll/cpl/input/keysettings.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/input/keysettings.…
==============================================================================
--- trunk/reactos/dll/cpl/input/keysettings.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/input/keysettings.c [iso-8859-1] Sun Apr 20 02:34:59 2008
@@ -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(a)yandex.ru)
+ * Colin Finck
* UPDATE HISTORY:
* 06-09-2007 Created
*/
Modified: trunk/reactos/dll/cpl/input/settings.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/input/settings.c?r…
==============================================================================
--- trunk/reactos/dll/cpl/input/settings.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/input/settings.c [iso-8859-1] Sun Apr 20 02:34:59 2008
@@ -4,6 +4,7 @@
* FILE: dll/win32/input/settings.c
* PURPOSE: input.dll
* PROGRAMMER: Dmitry Chapyshev (dmitry(a)reactos.org)
+ * Colin Finck
* UPDATE HISTORY:
* 06-09-2007 Created
*/
@@ -12,6 +13,8 @@
#include "input.h"
#define BUFSIZE 256
+
+static HWND MainDlgWnd;
typedef struct
{
@@ -81,13 +84,11 @@
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 @@
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 @@
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 @@
{
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 @@
case WM_COMMAND:
switch (LOWORD(wParam))
{
+ case IDC_REMOVE_BUTTON:
+ DeleteLayout();
+ break;
+
case IDC_KEY_SET_BTN:
DialogBox(hApplet,
MAKEINTRESOURCE(IDD_KEYSETTINGS),