Author: janderwald
Date: Mon Sep 4 17:13:42 2006
New Revision: 23911
URL:
http://svn.reactos.org/svn/reactos?rev=23911&view=rev
Log:
* move reading / applying options out of console.dll
* remove unused code
* notify win32csr when a property has changed
Modified:
trunk/reactos/dll/win32/console/console.c
trunk/reactos/dll/win32/console/console.h
trunk/reactos/dll/win32/console/en.rc
trunk/reactos/dll/win32/console/options.c
Modified: trunk/reactos/dll/win32/console/console.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/console/console.…
==============================================================================
--- trunk/reactos/dll/win32/console/console.c (original)
+++ trunk/reactos/dll/win32/console/console.c Mon Sep 4 17:13:42 2006
@@ -60,19 +60,18 @@
}
PConsoleInfo
-InitConsoleInfo()
+AllocConsoleInfo()
{
PConsoleInfo pConInfo;
- STARTUPINFO StartupInfo;
- TCHAR * ptr;
- SIZE_T length;
pConInfo = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ConsoleInfo));
- if (!pConInfo)
- {
- return NULL;
- }
-
+
+ return pConInfo;
+}
+
+void
+InitConsoleDefaults(PConsoleInfo pConInfo)
+{
/* initialize struct */
pConInfo->InsertMode = TRUE;
pConInfo->HistoryBufferSize = 50;
@@ -88,49 +87,9 @@
pConInfo->FontSize = (DWORD)MAKELONG(8, 12);
pConInfo->FontWeight = FALSE;
memcpy(pConInfo->Colors, s_Colors, sizeof(s_Colors));
-
- GetModuleFileName(NULL, pConInfo->szProcessName, MAX_PATH);
- GetStartupInfo(&StartupInfo);
-
-
-
- if ( StartupInfo.lpTitle )
- {
- if ( _tcslen(StartupInfo.lpTitle) )
- {
- if ( !GetWindowsDirectory(pConInfo->szProcessName, MAX_PATH) )
- {
- HeapFree(GetProcessHeap(), 0, pConInfo);
- return FALSE;
- }
- length = _tcslen(pConInfo->szProcessName);
- if ( !_tcsncmp(pConInfo->szProcessName, StartupInfo.lpTitle, length) )
- {
- // Windows XP SP2 uses unexpanded environment vars to get path
- // i.e. c:\windows\system32\cmd.exe
- // becomes
- // %SystemRoot%_system32_cmd.exe
-
- _tcscpy(pConInfo->szProcessName, _T("%SystemRoot%"));
- _tcsncpy(&pConInfo->szProcessName[12], &StartupInfo.lpTitle[length],
_tcslen(StartupInfo.lpTitle) - length + 1);
-
- ptr = &pConInfo->szProcessName[12];
- while( (ptr = _tcsstr(ptr, _T("\\"))) )
- ptr[0] = _T('_');
- }
- }
- else
- {
- _tcscpy(pConInfo->szProcessName, _T("Console"));
- }
- }
- else
- {
- _tcscpy(pConInfo->szProcessName, _T("Console"));
- }
- return pConInfo;
-}
-
+}
+
+
INT_PTR
CALLBACK
ApplyProc(
@@ -148,11 +107,7 @@
{
case WM_INITDIALOG:
{
-#if 0
hDlgCtrl = GetDlgItem(hwndDlg, IDC_RADIO_APPLY_CURRENT);
-#else
- hDlgCtrl = GetDlgItem(hwndDlg, IDC_RADIO_APPLY_ALL);
-#endif
SendMessage(hDlgCtrl, BM_SETCHECK, BST_CHECKED, 0);
return TRUE;
}
@@ -193,19 +148,15 @@
}
else if ( res == IDC_RADIO_APPLY_ALL )
{
- /* apply options */
- WriteConsoleOptions(pConInfo);
pConInfo->AppliedConfig = TRUE;
SetWindowLong(hwndDlg, DWL_MSGRESULT, PSNRET_NOERROR);
+ SendMessage(pConInfo->hConsoleWindow, PM_APPLY_CONSOLE_INFO, (WPARAM)pConInfo,
(LPARAM)TRUE);
}
else if ( res == IDC_RADIO_APPLY_CURRENT )
{
- /*
- * TODO:
- * exchange info in some private way with win32csr
- */
pConInfo->AppliedConfig = TRUE;
SetWindowLong(hwndDlg, DWL_MSGRESULT, PSNRET_NOERROR);
+ SendMessage(pConInfo->hConsoleWindow, PM_APPLY_CONSOLE_INFO, (WPARAM)pConInfo,
(LPARAM)TRUE);
}
}
@@ -218,16 +169,68 @@
INT i=0;
PConsoleInfo pConInfo;
- UNREFERENCED_PARAMETER(hwnd);
UNREFERENCED_PARAMETER(uMsg);
- UNREFERENCED_PARAMETER(wParam);
- UNREFERENCED_PARAMETER(lParam);
-
- pConInfo = InitConsoleInfo();
+
+ /*
+ * console.dll shares information with win32csr with wParam, lParam
+ *
+ * wParam is a file handle to an unamed file object which contains the ConsoleInfo
struct
+ * lParam is a boolean parameter which specifies wheter defaults should be shown
+ */
+
+ pConInfo = AllocConsoleInfo();
+ if (!pConInfo)
+ {
+ return 0;
+ }
+
+ if (lParam)
+ {
+ /* use defaults */
+ InitConsoleDefaults(pConInfo);
+ }
+ else
+ {
+ /* use current info */
+ PConsoleInfo pSharedInfo = MapViewOfFile((HANDLE)wParam,
+ FILE_MAP_ALL_ACCESS,
+ 0,
+ 0,
+ sizeof(ConsoleInfo));
+
+ /* copy options */
+ if (pSharedInfo)
+ {
+ pConInfo->InsertMode = pSharedInfo->InsertMode;
+ pConInfo->HistoryBufferSize = pSharedInfo->HistoryBufferSize;
+ pConInfo->NumberOfHistoryBuffers = pSharedInfo->NumberOfHistoryBuffers;
+ pConInfo->ScreenText = pSharedInfo->ScreenText;
+ pConInfo->ScreenBackground = pSharedInfo->ScreenBackground;
+ pConInfo->PopupText = pSharedInfo->PopupText;
+ pConInfo->PopupBackground = pSharedInfo->PopupBackground;
+ pConInfo->WindowSize = pSharedInfo->WindowSize;
+ pConInfo->WindowPosition = pSharedInfo->WindowPosition;
+ pConInfo->ScreenBuffer = pSharedInfo->ScreenBuffer;
+ pConInfo->UseRasterFonts = pSharedInfo->UseRasterFonts;
+ pConInfo->FontSize = pSharedInfo->FontSize;
+ pConInfo->FontWeight = pSharedInfo->FontWeight;
+ memcpy(pConInfo->Colors, pSharedInfo->Colors, sizeof(s_Colors));
+ }
+ }
+
+ /* console window -> is notified on a property change event */
+ pConInfo->hConsoleWindow = hwnd;
ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
psh.dwSize = sizeof(PROPSHEETHEADER);
- psh.dwFlags = PSH_PROPSHEETPAGE | PSH_PROPTITLE | PSH_NOAPPLYNOW;
+ psh.dwFlags = PSH_PROPSHEETPAGE | PSH_NOAPPLYNOW;
+
+ if(_tcslen(pConInfo->szProcessName))
+ {
+ psh.dwFlags |= PSH_PROPTITLE;
+ psh.pszCaption = pConInfo->szProcessName;
+ }
+
psh.hwndParent = NULL;
psh.hInstance = hApplet;
psh.hIcon = LoadIcon(hApplet, MAKEINTRESOURCE(IDC_CPLICON));
@@ -235,8 +238,7 @@
psh.nPages = 4;
psh.nStartPage = 0;
psh.ppsp = psp;
- psh.pszCaption = pConInfo->szProcessName;
-
+
InitPropSheetPage(&psp[i++], IDD_PROPPAGEOPTIONS, (DLGPROC) OptionsProc,
(LPARAM)pConInfo);
InitPropSheetPage(&psp[i++], IDD_PROPPAGEFONT, (DLGPROC) FontProc,
(LPARAM)pConInfo);
InitPropSheetPage(&psp[i++], IDD_PROPPAGELAYOUT, (DLGPROC) LayoutProc,
(LPARAM)pConInfo);
Modified: trunk/reactos/dll/win32/console/console.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/console/console.…
==============================================================================
--- trunk/reactos/dll/win32/console/console.h (original)
+++ trunk/reactos/dll/win32/console/console.h Mon Sep 4 17:13:42 2006
@@ -21,11 +21,14 @@
typedef struct TAGConsoleInfo
{
+ HANDLE hFile;
+ HWND hConsoleWindow;
TCHAR szProcessName[MAX_PATH];
BOOLEAN AppliedConfig;
BOOLEAN UseRasterFonts;
DWORD FontSize;
DWORD FontWeight;
+ FONTSIGNATURE FontSignature;
DWORD CursorSize;
DWORD NumberOfHistoryBuffers;
DWORD HistoryBufferSize;
@@ -44,10 +47,11 @@
COLORREF Colors[16];
} ConsoleInfo, *PConsoleInfo;
-BOOL WriteConsoleOptions(PConsoleInfo pConInfo);
void ApplyConsoleInfo(HWND hwndDlg, PConsoleInfo pConInfo);
void PaintConsole(LPDRAWITEMSTRUCT drawItem, PConsoleInfo pConInfo);
void PaintText(LPDRAWITEMSTRUCT drawItem, PConsoleInfo pConInfo);
+
+#define PM_APPLY_CONSOLE_INFO (WM_APP + 100)
//globals
Modified: trunk/reactos/dll/win32/console/en.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/console/en.rc?re…
==============================================================================
--- trunk/reactos/dll/win32/console/en.rc (original)
+++ trunk/reactos/dll/win32/console/en.rc Mon Sep 4 17:13:42 2006
@@ -135,7 +135,7 @@
CAPTION "Apply Properties"
FONT 8, "MS Shell Dlg"
BEGIN
-CONTROL "&Apply Properties to current window only",
IDC_RADIO_APPLY_CURRENT, "Button", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE |
WS_TABSTOP | WS_DISABLED, 25, 25, 150, 10
+CONTROL "&Apply Properties to current window only",
IDC_RADIO_APPLY_CURRENT, "Button", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE |
WS_TABSTOP, 25, 25, 150, 10
CONTROL "&Save Properties for future windows with same title",
IDC_RADIO_APPLY_ALL, "Button", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE |
WS_TABSTOP, 25, 40, 185, 10
PUSHBUTTON "OK", IDOK, 25, 80, 40, 15, WS_VISIBLE
PUSHBUTTON "Cancel", IDCANCEL, 120, 80, 50, 15, WS_VISIBLE
Modified: trunk/reactos/dll/win32/console/options.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/console/options.…
==============================================================================
--- trunk/reactos/dll/win32/console/options.c (original)
+++ trunk/reactos/dll/win32/console/options.c Mon Sep 4 17:13:42 2006
@@ -12,10 +12,6 @@
static
void
UpdateDialogElements(HWND hwndDlg, PConsoleInfo pConInfo);
-
-static
-BOOL
-InitializeOptionsFromReg(TCHAR * Path, PConsoleInfo pConInfo);
INT_PTR
CALLBACK
@@ -39,7 +35,6 @@
{
pConInfo = (PConsoleInfo) ((LPPROPSHEETPAGE)lParam)->lParam;
SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pConInfo);
- InitializeOptionsFromReg(pConInfo->szProcessName, pConInfo);
UpdateDialogElements(hwndDlg, pConInfo);
return TRUE;
}
@@ -59,11 +54,6 @@
pConInfo->NumberOfHistoryBuffers = LOWORD(SendMessage(hDlgCtrl, UDM_GETPOS, 0,
0));
PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
}
- //else if (lppsn->hdr.code == PSN_KILLACTIVE)
- //{
- // SetWindowLong(hwndDlg, DWL_MSGRESULT, FALSE);
- // return FALSE;
- //}
else if (lppsn->hdr.code == PSN_APPLY)
{
if (!pConInfo->AppliedConfig)
@@ -176,91 +166,6 @@
}
return FALSE;
-}
-
-static
-BOOL InitializeOptionsFromReg(TCHAR * Path, PConsoleInfo pConInfo)
-{
- HKEY hKey;
- HKEY hSubKey;
- DWORD dwNumSubKeys = 0;
- DWORD dwIndex;
- DWORD dwValueName;
- DWORD dwValue;
- DWORD dwType;
- TCHAR szValueName[MAX_PATH];
- TCHAR szValue[MAX_PATH];
- DWORD Value;
-
- if ( RegOpenCurrentUser(KEY_READ, &hKey) != ERROR_SUCCESS )
- return FALSE;
-
-
- if ( RegOpenKeyEx(hKey, Path, 0, KEY_READ, &hSubKey) != ERROR_SUCCESS)
- {
- RegCloseKey(hKey);
- return FALSE;
- }
-
- RegQueryInfoKey(hSubKey, NULL, NULL, NULL, &dwNumSubKeys, NULL, NULL, NULL, NULL,
NULL, NULL, NULL );
-
- for (dwIndex = 0; dwIndex < dwNumSubKeys; dwIndex++)
- {
- dwValue = sizeof(Value);
- dwValueName = MAX_PATH;
-
- if ( RegEnumValue(hSubKey, dwIndex, szValueName, &dwValueName, NULL,
&dwType, (BYTE*)&Value, &dwValue) != ERROR_SUCCESS)
- {
- if (dwType == REG_SZ)
- {
- /*
- * retry in case of string value
- */
- dwValue = sizeof(szValue);
- dwValueName = MAX_PATH;
- if (RegEnumValue(hSubKey, dwIndex, szValueName, &dwValueName, NULL,
NULL, (BYTE*)szValue, &dwValue) != ERROR_SUCCESS)
- break;
- }
- else
- break;
- }
-
- if ( !_tcscmp(szValueName, _T("CursorSize")) )
- {
- if ( Value == 0x32)
- pConInfo->CursorSize = Value;
- else if ( Value == 0x64 )
- pConInfo->CursorSize = Value;
- }
- else if ( !_tcscmp(szValueName, _T("NumberOfHistoryBuffers")) )
- {
- pConInfo->NumberOfHistoryBuffers = Value;
- }
- else if ( !_tcscmp(szValueName, _T("HistoryBufferSize")) )
- {
- pConInfo->HistoryBufferSize = Value;
- }
- else if ( !_tcscmp(szValueName, _T("HistoryNoDup")) )
- {
- pConInfo->HistoryNoDup = Value;
- }
- else if ( !_tcscmp(szValueName, _T("FullScreen")) )
- {
- pConInfo->FullScreen = Value;
- }
- else if ( !_tcscmp(szValueName, _T("QuickEdit")) )
- {
- pConInfo->QuickEdit = Value;
- }
- else if ( !_tcscmp(szValueName, _T("InsertMode")) )
- {
- pConInfo->InsertMode = Value;
- }
- }
-
- RegCloseKey(hKey);
- RegCloseKey(hSubKey);
- return TRUE;
}
static
@@ -360,69 +265,3 @@
}
-BOOLEAN InitializeOptionsDialog(HWND hwndDlg)
-{
- PConsoleInfo pConInfo = (PConsoleInfo) GetWindowLongPtr(GetParent(hwndDlg), DWLP_USER);
-
- if (!pConInfo)
- return FALSE;
-
-
- return TRUE;
-}
-
-BOOL WriteConsoleOptions(PConsoleInfo pConInfo)
-{
- HKEY hKey;
- HKEY hSubKey;
-
- if ( RegOpenCurrentUser(KEY_READ | KEY_SET_VALUE, &hKey) != ERROR_SUCCESS )
- return FALSE;
-
-
- if ( RegOpenKeyEx(hKey, pConInfo->szProcessName, 0, KEY_READ | KEY_SET_VALUE,
&hSubKey) != ERROR_SUCCESS)
- {
- RegCloseKey(hKey);
- return FALSE;
- }
-
- if ( pConInfo->CursorSize == 0x0)
- RegDeleteKey(hSubKey, _T("CursorSize"));
- else
- RegSetValueEx(hSubKey, _T("CursorSize"), 0, REG_DWORD, (const BYTE
*)&pConInfo->CursorSize, sizeof(DWORD));
-
- if ( pConInfo->NumberOfHistoryBuffers == 0x5 )
- RegDeleteKey(hSubKey, _T("NumberOfHistoryBuffers"));
- else
- RegSetValueEx(hSubKey, _T("NumberOfHistoryBuffers"), 0, REG_DWORD, (const
BYTE *)&pConInfo->NumberOfHistoryBuffers, sizeof(DWORD));
-
- if ( pConInfo->HistoryBufferSize == 50 )
- RegDeleteKey(hSubKey, _T("HistoryBufferSize"));
- else
- RegSetValueEx(hSubKey, _T("HistoryBufferSize"), 0, REG_DWORD, (const BYTE
*)&pConInfo->HistoryBufferSize, sizeof(DWORD));
-
- if ( pConInfo->FullScreen == FALSE )
- RegDeleteKey(hSubKey, _T("FullScreen"));
- else
- RegSetValueEx(hSubKey, _T("FullScreen"), 0, REG_DWORD, (const BYTE
*)&pConInfo->FullScreen, sizeof(DWORD));
-
- if ( pConInfo->QuickEdit == FALSE)
- RegDeleteKey(hSubKey, _T("QuickEdit"));
- else
- RegSetValueEx(hSubKey, _T("QuickEdit"), 0, REG_DWORD, (const BYTE
*)&pConInfo->QuickEdit, sizeof(DWORD));
-
- if ( pConInfo->InsertMode == TRUE )
- RegDeleteKey(hSubKey, _T("InsertMode"));
- else
- RegSetValueEx(hSubKey, _T("InsertMode"), 0, REG_DWORD, (const BYTE
*)&pConInfo->InsertMode, sizeof(DWORD));
-
- if ( pConInfo->HistoryNoDup == FALSE )
- RegDeleteKey(hSubKey, _T("HistoryNoDup"));
- else
- RegSetValueEx(hSubKey, _T("HistoryNoDup"), 0, REG_DWORD, (const BYTE
*)&pConInfo->HistoryNoDup, sizeof(DWORD));
-
- RegCloseKey(hKey);
- RegCloseKey(hSubKey);
-
- return TRUE;
-}