* remove unreferenced parameters warning in font.c layout.c colors.c

* remove global structure g_ConsoleInfo
* implemented reading/writing of options dialog settings
* added apply dialog
* thnx to w3seek for help

svn path=/trunk/; revision=22820
This commit is contained in:
Johannes Anderwald 2006-07-04 13:22:05 +00:00
parent 4b35b55e7a
commit 2cb63fcb9b
8 changed files with 460 additions and 158 deletions

View file

@ -18,6 +18,10 @@ ColorsProc(
LPARAM lParam
)
{
UNREFERENCED_PARAMETER(hwndDlg)
UNREFERENCED_PARAMETER(wParam)
UNREFERENCED_PARAMETER(lParam)
switch(uMsg)
{
case WM_INITDIALOG:

View file

@ -36,6 +36,129 @@ InitPropSheetPage(PROPSHEETPAGE *psp, WORD idDlg, DLGPROC DlgProc)
psp->pfnDlgProc = DlgProc;
}
BOOL
InitConsoleInfo(HWND hwnd)
{
PConsoleInfo pConInfo;
STARTUPINFO StartupInfo;
TCHAR * ptr;
SIZE_T length;
pConInfo = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ConsoleInfo));
if (!pConInfo)
return FALSE;
/* initialize struct */
pConInfo->InsertMode = TRUE;
pConInfo->HistoryBufferSize = 50;
pConInfo->NumberOfHistoryBuffers = 5;
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"));
}
SetWindowText(hwnd, pConInfo->szProcessName);
SetWindowLongPtr(hwnd, DWLP_USER , (LONG)pConInfo);
return TRUE;
}
INT_PTR
CALLBACK
ApplyProc(
HWND hwndDlg,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
)
{
HWND hDlgCtrl;
UNREFERENCED_PARAMETER(lParam)
switch(uMsg)
{
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;
}
case WM_COMMAND:
{
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
{
hDlgCtrl = GetDlgItem(hwndDlg, IDC_RADIO_APPLY_CURRENT);
if ( SendMessage(hDlgCtrl, BM_GETCHECK, 0, 0) == BST_CHECKED )
EndDialog(hwndDlg, IDC_RADIO_APPLY_CURRENT);
else
EndDialog(hwndDlg, IDC_RADIO_APPLY_ALL);
}
break;
}
default:
break;
}
return FALSE;
}
void
ApplyConsoleInfo(HWND hwndDlg, PConsoleInfo pConInfo)
{
INT_PTR res;
res = DialogBox(hApplet, MAKEINTRESOURCE(IDD_APPLYOPTIONS), hwndDlg, ApplyProc);
if ( res == IDC_RADIO_APPLY_ALL )
{
WriteConsoleOptions(pConInfo);
}
else if ( res == IDC_RADIO_APPLY_CURRENT )
{
/*
* TODO: check if szProcessName != _T("Console")
* in that case notify win32csr that the changes are local
*/
}
}
/* Property Sheet Callback */
int CALLBACK
@ -45,66 +168,78 @@ PropSheetProc(
LPARAM lParam
)
{
UNREFERENCED_PARAMETER(hwndDlg)
switch(uMsg)
{
case PSCB_BUTTONPRESSED:
switch(lParam)
{
case PSBTN_OK: /* OK */
break;
case PSBTN_CANCEL: /* Cancel */
break;
case PSBTN_APPLYNOW: /* Apply now */
break;
case PSBTN_FINISH: /* Close */
break;
default:
return FALSE;
}
break;
case PSCB_INITIALIZED:
break;
}
return TRUE;
PConsoleInfo pConInfo = (PConsoleInfo) GetWindowLongPtr(hwndDlg, DWLP_USER);
switch(uMsg)
{
case PSCB_BUTTONPRESSED:
{
switch(lParam)
{
case PSBTN_OK: /* OK */
{
if ( pConInfo )
{
ApplyConsoleInfo(hwndDlg, pConInfo);
}
break;
}
case PSBTN_CANCEL: /* Cancel */
{
break;
}
case PSBTN_FINISH: /* Close */
{
break;
}
default:
return FALSE;
}
break;
}
case PSCB_INITIALIZED:
{
break;
}
default:
break;
}
return TRUE;
}
/* First Applet */
LONG APIENTRY
InitApplet(HWND hwnd, UINT uMsg, LONG wParam, LONG lParam)
{
PROPSHEETPAGE psp[5];
PROPSHEETHEADER psh;
TCHAR Caption[1024];
INT i=0;
UNREFERENCED_PARAMETER(hwnd)
UNREFERENCED_PARAMETER(uMsg)
UNREFERENCED_PARAMETER(wParam)
UNREFERENCED_PARAMETER(lParam)
PROPSHEETPAGE psp[4];
PROPSHEETHEADER psh;
INT i=0;
memset(Caption, 0x0, sizeof(Caption));
LoadString(hApplet, IDS_CPLNAME, Caption, sizeof(Caption) / sizeof(TCHAR));
UNREFERENCED_PARAMETER(hwnd)
UNREFERENCED_PARAMETER(uMsg)
UNREFERENCED_PARAMETER(wParam)
UNREFERENCED_PARAMETER(lParam)
ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
psh.dwSize = sizeof(PROPSHEETHEADER);
psh.dwFlags = PSH_PROPSHEETPAGE | PSH_NOAPPLYNOW | PSH_PROPTITLE | PSH_USECALLBACK;
psh.hwndParent = NULL;
psh.hInstance = hApplet;
psh.hIcon = LoadIcon(hApplet, MAKEINTRESOURCE(IDC_CPLICON));
psh.pszCaption = 0;
psh.nPages = 4;
psh.nStartPage = 0;
psh.ppsp = psp;
psh.pfnCallback = PropSheetProc;
ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
psh.dwSize = sizeof(PROPSHEETHEADER);
psh.dwFlags = PSH_PROPSHEETPAGE | PSH_USECALLBACK | PSH_PROPTITLE;
psh.hwndParent = NULL;
psh.hInstance = hApplet;
psh.hIcon = LoadIcon(hApplet, MAKEINTRESOURCE(IDC_CPLICON));
psh.pszCaption = Caption;
psh.nPages = 4;
psh.nStartPage = 0;
psh.ppsp = psp;
psh.pfnCallback = PropSheetProc;
InitPropSheetPage(&psp[i++], IDD_PROPPAGEOPTIONS, (DLGPROC) OptionsProc);
InitPropSheetPage(&psp[i++], IDD_PROPPAGEFONT, (DLGPROC) FontProc);
InitPropSheetPage(&psp[i++], IDD_PROPPAGELAYOUT, (DLGPROC) LayoutProc);
InitPropSheetPage(&psp[i++], IDD_PROPPAGECOLORS, (DLGPROC) ColorsProc);
return (LONG)(PropertySheet(&psh) != -1);
InitPropSheetPage(&psp[i++], IDD_PROPPAGEOPTIONS, (DLGPROC) OptionsProc);
InitPropSheetPage(&psp[i++], IDD_PROPPAGEFONT, (DLGPROC) FontProc);
InitPropSheetPage(&psp[i++], IDD_PROPPAGELAYOUT, (DLGPROC) LayoutProc);
InitPropSheetPage(&psp[i++], IDD_PROPPAGECOLORS, (DLGPROC) ColorsProc);
return (PropertySheet(&psh) != -1);
}
/* Control Panel Callback */
@ -116,7 +251,7 @@ CPlApplet(
LPARAM lParam2)
{
int i = (int)lParam1;
switch(uMsg)
{
case CPL_INIT:
@ -130,7 +265,6 @@ CPlApplet(
case CPL_INQUIRE:
{
CPLINFO *CPlInfo = (CPLINFO*)lParam2;
CPlInfo->lData = 0;
CPlInfo->idIcon = Applets[i].idIcon;
CPlInfo->idName = Applets[i].idName;
CPlInfo->idInfo = Applets[i].idDescription;
@ -146,7 +280,7 @@ CPlApplet(
}
BOOLEAN
INT
WINAPI
DllMain(
HINSTANCE hinstDLL,
@ -155,12 +289,6 @@ DllMain(
{
UNREFERENCED_PARAMETER(lpvReserved)
/* initialize global struct */
memset(&g_ConsoleInfo, 0x0, sizeof(ConsoleInfo));
g_ConsoleInfo.InsertMode = TRUE;
g_ConsoleInfo.HistoryBufferSize = 50;
g_ConsoleInfo.NumberOfHistoryBuffers = 5;
switch(dwReason)
{
case DLL_PROCESS_ATTACH:

View file

@ -20,7 +20,7 @@ typedef struct
typedef struct TAGConsoleInfo
{
LPSTR szProcessName;
TCHAR szProcessName[MAX_PATH];
DWORD CursorSize;
DWORD NumberOfHistoryBuffers;
DWORD HistoryBufferSize;
@ -31,6 +31,7 @@ typedef struct TAGConsoleInfo
} ConsoleInfo, *PConsoleInfo;
extern ConsoleInfo g_ConsoleInfo;
BOOL WriteConsoleOptions(PConsoleInfo pConInfo);
BOOL InitConsoleInfo(HWND hwnd);
#endif /* CONSOLE_H__ */

View file

@ -10,18 +10,18 @@
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
IDD_PROPPAGEOPTIONS DIALOGEX 0, 0, 250, 220
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_DISABLED | WS_CAPTION
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_CAPTION
CAPTION "Options"
FONT 8, "MS Shell Dlg"
BEGIN
GROUPBOX "Cursor Size", -1, 15, 15, 120, 70
CONTROL "&Small", IDC_RADIO_SMALL_CURSOR, "Button", 0x50010009, 25, 25, 90, 10
CONTROL "&Medium", IDC_RADIO_MEDIUM_CURSOR, "Button", 0x50010009, 25, 40, 90, 10
CONTROL "&Large", IDC_RADIO_LARGE_CURSOR, "Button", 0x50010009, 25, 55, 90, 10
GROUPBOX "Display Options", -1, 140, 15, 100, 70
CONTROL "&Window", IDC_RADIO_DISPLAY_WINDOW, "Button", 0x50010009, 150, 35, 70, 10
CONTROL "F&ull Screen", IDC_RADIO_DISPLAY_FULL, "Button", 0x50010009, 150, 50, 70, 10
GROUPBOX "Command History:", -1, 15, 90, 120, 70
GROUPBOX "Cursor Size", -1, 15, 15, 120, 70, WS_CHILD | WS_VISIBLE | WS_GROUP
CONTROL "&Small", IDC_RADIO_SMALL_CURSOR, "Button", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 25, 25, 90, 10
CONTROL "&Medium", IDC_RADIO_MEDIUM_CURSOR, "Button", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 25, 40, 90, 10
CONTROL "&Large", IDC_RADIO_LARGE_CURSOR, "Button", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 25, 55, 90, 10
GROUPBOX "Display Options", -1, 140, 15, 100, 70, WS_CHILD | WS_VISIBLE | WS_GROUP
CONTROL "&Window", IDC_RADIO_DISPLAY_WINDOW, "Button", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 150, 35, 70, 10
CONTROL "F&ull Screen", IDC_RADIO_DISPLAY_FULL, "Button", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 150, 50, 70, 10
GROUPBOX "Command History:", -1, 15, 90, 120, 70, WS_CHILD | WS_VISIBLE | WS_GROUP
LTEXT "&Buffer Size", -1, 25, 100, 60, 15
EDITTEXT IDC_EDIT_BUFFER_SIZE, 90, 100, 30, 15, ES_RIGHT | WS_GROUP
CONTROL "", IDC_UPDOWN_BUFFER_SIZE, UPDOWN_CLASS,UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_BORDER | WS_GROUP, 115, 100, 12, 12
@ -31,13 +31,13 @@ CONTROL "", IDC_UPDOWN_NUM_BUFFER, UPDOWN_CLASS,UDS_SETBUDDYINT | UDS_ALIGNRIGH
CHECKBOX "&Discard Old Duplicates", IDC_CHECK_DISCARD_DUPLICATES, 25, 140, 100, 15
GROUPBOX "Edit Options", -1, 140, 90, 100, 70
CHECKBOX "&QuickEdit Mode", IDC_CHECK_QUICK_EDIT, 150, 100, 60, 15
CHECKBOX "&Insert Mode", IDC_CHECK_INSERT_MODE, 150, 120, 60, 15
GROUPBOX "Edit Options", -1, 140, 90, 100, 70, BS_GROUPBOX | WS_CHILD | WS_VISIBLE | WS_GROUP
CHECKBOX "&QuickEdit Mode", IDC_CHECK_QUICK_EDIT, 150, 100, 60, 15, WS_CHILD | WS_VISIBLE | WS_TABSTOP
CHECKBOX "&Insert Mode", IDC_CHECK_INSERT_MODE, 150, 120, 60, 15, WS_CHILD | WS_VISIBLE | WS_TABSTOP
END
IDD_PROPPAGEFONT DIALOGEX 0, 0, 220, 220
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_DISABLED | WS_CAPTION
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_CAPTION
CAPTION "Font"
FONT 8, "MS Shell Dlg"
BEGIN
@ -45,7 +45,7 @@ LTEXT "This space is intentionally left blank", -1, 55, 103, 120, 10
END
IDD_PROPPAGELAYOUT DIALOGEX 0, 0, 220, 220
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_DISABLED | WS_CAPTION
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_CAPTION
CAPTION "Layout"
FONT 8, "MS Shell Dlg"
BEGIN
@ -53,15 +53,27 @@ LTEXT "This space is intentionally left blank", -1, 55, 103, 120, 10
END
IDD_PROPPAGECOLORS DIALOGEX 0, 0, 220, 220
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_DISABLED | WS_CAPTION
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_CAPTION
CAPTION "Colors"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "This space is intentionally left blank", -1, 55, 103, 120, 10
END
IDD_APPLYOPTIONS DIALOGEX 0, 0, 220, 100
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_CAPTION
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 "&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
END
STRINGTABLE
BEGIN
IDS_CPLNAME "Console"
IDS_CPLDESCRIPTION "Configures console properties."
IDS_APPLY_SHORTCUT_ALL "Modify &shortcut that started this window"
END

View file

@ -19,6 +19,10 @@ FontProc(
LPARAM lParam
)
{
UNREFERENCED_PARAMETER(hwndDlg)
UNREFERENCED_PARAMETER(wParam)
UNREFERENCED_PARAMETER(lParam)
switch(uMsg)
{
case WM_INITDIALOG:

View file

@ -18,6 +18,10 @@ LayoutProc(
LPARAM lParam
)
{
UNREFERENCED_PARAMETER(hwndDlg)
UNREFERENCED_PARAMETER(wParam)
UNREFERENCED_PARAMETER(lParam)
switch(uMsg)
{
case WM_INITDIALOG:

View file

@ -9,9 +9,6 @@
#include "console.h"
ConsoleInfo g_ConsoleInfo;
BOOLEAN InitializeOptionsDialog();
INT_PTR
@ -23,11 +20,128 @@ OptionsProc(
LPARAM lParam
)
{
PConsoleInfo pConInfo;
LRESULT lResult;
HWND hDlgCtrl;
LPPSHNOTIFY lppsn;
pConInfo = (PConsoleInfo) GetWindowLongPtr(GetParent(hwndDlg), DWLP_USER);
switch(uMsg)
{
case WM_INITDIALOG:
{
return InitializeOptionsDialog(hwndDlg);
}
case WM_NOTIFY:
{
if (!pConInfo)
{
break;
}
lppsn = (LPPSHNOTIFY) lParam;
if (lppsn->hdr.code == UDN_DELTAPOS)
{
hDlgCtrl = GetDlgItem(hwndDlg, IDC_EDIT_BUFFER_SIZE);
pConInfo->HistoryBufferSize = LOWORD(SendMessage(hDlgCtrl, UDM_GETPOS, 0, 0));
hDlgCtrl = GetDlgItem(hwndDlg, IDC_EDIT_NUM_BUFFER);
pConInfo->NumberOfHistoryBuffers = LOWORD(SendMessage(hDlgCtrl, UDM_GETPOS, 0, 0));
//PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
}
break;
}
case WM_COMMAND:
{
if (!pConInfo)
{
break;
}
switch(LOWORD(wParam))
{
case IDC_RADIO_SMALL_CURSOR:
{
pConInfo->CursorSize = 0x0;
//PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
break;
}
case IDC_RADIO_MEDIUM_CURSOR:
{
pConInfo->CursorSize = 0x32;
//PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
break;
}
case IDC_RADIO_LARGE_CURSOR:
{
pConInfo->CursorSize = 0x64;
//PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
break;
}
case IDC_RADIO_DISPLAY_WINDOW:
{
pConInfo->FullScreen = FALSE;
//PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
break;
}
case IDC_RADIO_DISPLAY_FULL:
{
pConInfo->FullScreen = TRUE;
//PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
break;
}
case IDC_CHECK_QUICK_EDIT:
{
lResult = SendMessage((HWND)lParam, BM_GETCHECK, (WPARAM)0, (LPARAM)0);
if (lResult == BST_CHECKED)
{
pConInfo->QuickEdit = FALSE;
SendMessage((HWND)lParam, BM_SETCHECK, (WPARAM)BST_UNCHECKED, (LPARAM)0);
}
else if (lResult == BST_UNCHECKED)
{
pConInfo->QuickEdit = TRUE;
SendMessage((HWND)lParam, BM_SETCHECK, (WPARAM)BST_CHECKED, (LPARAM)0);
}
//PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
break;
}
case IDC_CHECK_INSERT_MODE:
{
lResult = SendMessage((HWND)lParam, BM_GETCHECK, (WPARAM)0, (LPARAM)0);
if (lResult == BST_CHECKED)
{
pConInfo->InsertMode = FALSE;
SendMessage((HWND)lParam, BM_SETCHECK, (WPARAM)BST_UNCHECKED, (LPARAM)0);
}
else if (lResult == BST_UNCHECKED)
{
pConInfo->InsertMode = TRUE;
SendMessage((HWND)lParam, BM_SETCHECK, (WPARAM)BST_CHECKED, (LPARAM)0);
}
//PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
break;
}
case IDC_CHECK_DISCARD_DUPLICATES:
{
lResult = SendMessage((HWND)lParam, BM_GETCHECK, (WPARAM)0, (LPARAM)0);
if (lResult == BST_CHECKED)
{
pConInfo->HistoryNoDup = FALSE;
SendMessage((HWND)lParam, BM_SETCHECK, (WPARAM)BST_UNCHECKED, (LPARAM)0);
}
else if (lResult == BST_UNCHECKED)
{
pConInfo->HistoryNoDup = TRUE;
SendMessage((HWND)lParam, BM_SETCHECK, (WPARAM)BST_CHECKED, (LPARAM)0);
}
//PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
break;
}
default:
break;
}
break;
}
default:
break;
}
@ -35,7 +149,7 @@ OptionsProc(
return FALSE;
}
BOOL InitializeOptionsFromReg(TCHAR * Path)
BOOL InitializeOptionsFromReg(TCHAR * Path, PConsoleInfo pConInfo)
{
HKEY hKey;
HKEY hSubKey;
@ -66,37 +180,37 @@ BOOL InitializeOptionsFromReg(TCHAR * Path)
if ( RegEnumValue(hSubKey, dwIndex, szValueName, &dwValueName, NULL, NULL, (BYTE*)&Value, &dwValue) != ERROR_SUCCESS)
break;
if ( !_tcscmp(szValueName, _T("CursorSize")) )
{
if ( !_tcscmp(szValueName, _T("CursorSize")) )
{
if ( Value == 0x32)
g_ConsoleInfo.CursorSize = Value;
pConInfo->CursorSize = Value;
else if ( Value == 0x64 )
g_ConsoleInfo.CursorSize = Value;
pConInfo->CursorSize = Value;
}
else if ( !_tcscmp(szValueName, _T("NumberOfHistoryBuffers")) )
{
g_ConsoleInfo.NumberOfHistoryBuffers = Value;
}
else if ( !_tcscmp(szValueName, _T("HistoryBufferSize")) )
{
g_ConsoleInfo.HistoryBufferSize = Value;
}
else if ( !_tcscmp(szValueName, _T("HistoryNoDup")) )
{
g_ConsoleInfo.HistoryNoDup = Value;
}
else if ( !_tcscmp(szValueName, _T("FullScreen")) )
{
g_ConsoleInfo.FullScreen = Value;
}
else if ( !_tcscmp(szValueName, _T("QuickEdit")) )
{
g_ConsoleInfo.QuickEdit = Value;
}
else if ( !_tcscmp(szValueName, _T("InsertMode")) )
{
g_ConsoleInfo.InsertMode = Value;
}
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);
@ -105,13 +219,13 @@ BOOL InitializeOptionsFromReg(TCHAR * Path)
}
void
UpdateDialogElements(HWND hwndDlg)
UpdateDialogElements(HWND hwndDlg, PConsoleInfo pConInfo)
{
HWND hDlgCtrl;
TCHAR szBuffer[MAX_PATH];
/* update cursor size */
if ( g_ConsoleInfo.CursorSize == 0 )
if ( pConInfo->CursorSize == 0 )
{
/* small cursor */
hDlgCtrl = GetDlgItem(hwndDlg, IDC_RADIO_SMALL_CURSOR);
@ -122,7 +236,7 @@ UpdateDialogElements(HWND hwndDlg)
hDlgCtrl = GetDlgItem(hwndDlg, IDC_RADIO_LARGE_CURSOR);
SendMessage(hDlgCtrl, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
}
else if ( g_ConsoleInfo.CursorSize == 0x32 )
else if ( pConInfo->CursorSize == 0x32 )
{
hDlgCtrl = GetDlgItem(hwndDlg, IDC_RADIO_MEDIUM_CURSOR);
SendMessage(hDlgCtrl, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
@ -132,7 +246,7 @@ UpdateDialogElements(HWND hwndDlg)
hDlgCtrl = GetDlgItem(hwndDlg, IDC_RADIO_LARGE_CURSOR);
SendMessage(hDlgCtrl, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
}
else if ( g_ConsoleInfo.CursorSize == 0x64 )
else if ( pConInfo->CursorSize == 0x64 )
{
hDlgCtrl = GetDlgItem(hwndDlg, IDC_RADIO_LARGE_CURSOR);
SendMessage(hDlgCtrl, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
@ -144,24 +258,30 @@ UpdateDialogElements(HWND hwndDlg)
}
/* update num buffers */
hDlgCtrl = GetDlgItem(hwndDlg, IDC_UPDOWN_NUM_BUFFER);
SendMessage(hDlgCtrl, UDM_SETRANGE, 0, MAKELONG((short)999, (short)1));
hDlgCtrl = GetDlgItem(hwndDlg, IDC_EDIT_NUM_BUFFER);
_stprintf(szBuffer, _T("%d"), g_ConsoleInfo.NumberOfHistoryBuffers);
_stprintf(szBuffer, _T("%d"), pConInfo->NumberOfHistoryBuffers);
SendMessage(hDlgCtrl, WM_SETTEXT, 0, (LPARAM)szBuffer);
/* update buffer size */
hDlgCtrl = GetDlgItem(hwndDlg, IDC_UPDOWN_BUFFER_SIZE);
SendMessage(hDlgCtrl, UDM_SETRANGE, 0, MAKELONG((short)999, (short)1));
hDlgCtrl = GetDlgItem(hwndDlg, IDC_EDIT_BUFFER_SIZE);
_stprintf(szBuffer, _T("%d"), g_ConsoleInfo.HistoryBufferSize);
_stprintf(szBuffer, _T("%d"), pConInfo->HistoryBufferSize);
SendMessage(hDlgCtrl, WM_SETTEXT, 0, (LPARAM)szBuffer);
/* update discard duplicates */
hDlgCtrl = GetDlgItem(hwndDlg, IDC_CHECK_DISCARD_DUPLICATES);
if ( g_ConsoleInfo.HistoryNoDup )
if ( pConInfo->HistoryNoDup )
SendMessage(hDlgCtrl, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
else
SendMessage(hDlgCtrl, BM_SETCHECK, (LPARAM)BST_UNCHECKED, 0);
/* update full/window screen */
if ( g_ConsoleInfo.FullScreen )
if ( pConInfo->FullScreen )
{
hDlgCtrl = GetDlgItem(hwndDlg, IDC_RADIO_DISPLAY_FULL);
SendMessage(hDlgCtrl, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
@ -180,14 +300,14 @@ UpdateDialogElements(HWND hwndDlg)
/* update quick edit */
hDlgCtrl = GetDlgItem(hwndDlg, IDC_CHECK_QUICK_EDIT);
if ( g_ConsoleInfo.QuickEdit )
if ( pConInfo->QuickEdit )
SendMessage(hDlgCtrl, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
else
SendMessage(hDlgCtrl, BM_SETCHECK, (LPARAM)BST_UNCHECKED, 0);
/* update insert mode */
hDlgCtrl = GetDlgItem(hwndDlg, IDC_CHECK_INSERT_MODE);
if ( g_ConsoleInfo.InsertMode )
if ( pConInfo->InsertMode )
SendMessage(hDlgCtrl, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
else
SendMessage(hDlgCtrl, BM_SETCHECK, (LPARAM)BST_UNCHECKED, 0);
@ -196,52 +316,68 @@ UpdateDialogElements(HWND hwndDlg)
BOOLEAN InitializeOptionsDialog(HWND hwndDlg)
{
STARTUPINFO StartupInfo;
TCHAR szBuffer[MAX_PATH];
GetStartupInfo(&StartupInfo);
TCHAR * ptr;
DWORD length;
PConsoleInfo pConInfo = (PConsoleInfo) GetWindowLongPtr(GetParent(hwndDlg), DWLP_USER);
if ( StartupInfo.lpTitle )
if (!pConInfo)
return FALSE;
InitializeOptionsFromReg(pConInfo->szProcessName, pConInfo);
UpdateDialogElements(hwndDlg, pConInfo);
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)
{
if ( !GetWindowsDirectory(szBuffer, MAX_PATH) )
return FALSE;
length = _tcslen(szBuffer);
if ( !_tcsncmp(szBuffer, 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(szBuffer, _T("\%SystemRoot\%"));
_tcsncpy(&szBuffer[12], &StartupInfo.lpTitle[length], _tcslen(StartupInfo.lpTitle) - length + 1);
ptr = &szBuffer[12];
while( (ptr = _tcsstr(ptr, _T("\\"))) )
ptr[0] = _T('_');
}
if ( InitializeOptionsFromReg(szBuffer) )
{
UpdateDialogElements(hwndDlg);
return TRUE;
}
UpdateDialogElements(hwndDlg);
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 ( InitializeOptionsFromReg( _T("Console")) )
{
UpdateDialogElements(hwndDlg);
return TRUE;
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;
}

View file

@ -4,12 +4,15 @@
#define IDC_CPLICON 40
#define IDS_CPLNAME 41
#define IDS_CPLDESCRIPTION 42
#define IDS_APPLY_SHORTCUT_ALL 43
#define IDD_PROPPAGEOPTIONS 100
#define IDD_PROPPAGEFONT 101
#define IDD_PROPPAGELAYOUT 102
#define IDD_PROPPAGECOLORS 103
#define IDD_APPLYOPTIONS 104
//options dialog
#define IDC_CHECK_QUICK_EDIT 200
#define IDC_CHECK_INSERT_MODE 201
#define IDC_CHECK_DISCARD_DUPLICATES 202
@ -23,4 +26,14 @@
#define IDC_RADIO_DISPLAY_WINDOW 210
#define IDC_RADIO_DISPLAY_FULL 211
// apply dialog
#define IDC_RADIO_APPLY_ALL 300
#define IDC_RADIO_APPLY_CURRENT 301
//font dialog
#define IDC_CHECK_BOLD_FONTS 400
#endif