}
/* Initialize the font support */
- hCurrentFont = CreateConsoleFont(ConInfo);
- if (hCurrentFont == NULL)
- DPRINT1("InitApplet: CreateConsoleFont failed\n");
+ FontPreview.hFont = CreateConsoleFont(ConInfo);
+ if (FontPreview.hFont == NULL)
+ DPRINT1("InitApplet: CreateConsoleFont() failed\n");
+ GetFontCellSize(NULL, FontPreview.hFont, &FontPreview.CharHeight, &FontPreview.CharWidth);
/* Initialize the property sheet structure */
ZeroMemory(&psh, sizeof(psh));
psh.dwSize = sizeof(psh);
- psh.dwFlags = PSH_PROPSHEETPAGE | PSH_PROPTITLE | /* PSH_USEHICON */ PSH_USEICONID | PSH_NOAPPLYNOW | PSH_USECALLBACK;
+ psh.dwFlags = PSH_PROPSHEETPAGE | PSH_PROPTITLE | /* PSH_USEHICON | */ PSH_USEICONID | PSH_NOAPPLYNOW | PSH_USECALLBACK;
if (ConInfo->ConsoleTitle[0] != UNICODE_NULL)
- {
- wcsncpy(szTitle, L"\"", MAX_PATH);
- wcsncat(szTitle, ConInfo->ConsoleTitle, MAX_PATH - wcslen(szTitle));
- wcsncat(szTitle, L"\"", MAX_PATH - wcslen(szTitle));
- }
+ StringCchPrintfW(szTitle, ARRAYSIZE(szTitle), L"\"%s\"", ConInfo->ConsoleTitle);
else
- {
- wcscpy(szTitle, L"ReactOS Console");
- }
+ StringCchCopyW(szTitle, ARRAYSIZE(szTitle), L"ReactOS Console");
psh.pszCaption = szTitle;
if (pSharedInfo != NULL)
Result = PropertySheetW(&psh);
UnRegisterWinPrevClass(hApplet);
- /* First cleanup */
- if (hCurrentFont) DeleteObject(hCurrentFont);
- hCurrentFont = NULL;
+ /* Clear the font support */
+ if (FontPreview.hFont) DeleteObject(FontPreview.hFont);
+ FontPreview.hFont = NULL;
/* Save the console settings */
if (SetConsoleInfo)
Popup
} TEXT_TYPE;
+typedef struct _FONT_PREVIEW
+{
+ HFONT hFont;
+ UINT CharWidth;
+ UINT CharHeight;
+} FONT_PREVIEW;
+
/* Globals */
extern HINSTANCE hApplet;
extern PCONSOLE_STATE_INFO ConInfo;
-extern HFONT hCurrentFont;
+extern FONT_PREVIEW FontPreview;
VOID ApplyConsoleInfo(HWND hwndDlg);
* Current active font, corresponding to the active console font,
* and used for painting the text samples.
*/
-HFONT hCurrentFont = NULL;
+FONT_PREVIEW FontPreview = {NULL, 0, 0};
/*
IN PFONTSIZE_LIST_CTL SizeList,
IN OUT PCONSOLE_STATE_INFO pConInfo)
{
- HDC hDC;
- LONG CharWidth, CharHeight, FontSize;
+ LONG FontSize, CharWidth, CharHeight;
WCHAR szFontSize[100];
/*
CharHeight = (SizeList->UseRasterOrTTList ? (LONG)HIWORD(FontSize) : FontSize);
CharWidth = (SizeList->UseRasterOrTTList ? (LONG)LOWORD(FontSize) : 0);
- if (hCurrentFont) DeleteObject(hCurrentFont);
- hCurrentFont = CreateConsoleFont2(CharHeight, CharWidth, pConInfo);
- if (hCurrentFont == NULL)
- DPRINT1("FontSizeChange: CreateConsoleFont2 failed\n");
+ if (FontPreview.hFont) DeleteObject(FontPreview.hFont);
+ FontPreview.hFont = CreateConsoleFont2(CharHeight, CharWidth, pConInfo);
+ if (FontPreview.hFont == NULL)
+ DPRINT1("FontSizeChange: CreateConsoleFont2() failed\n");
/* Retrieve the real character size in pixels */
- hDC = GetDC(NULL);
- GetFontCellSize(hDC, hCurrentFont, (PUINT)&CharHeight, (PUINT)&CharWidth);
- ReleaseDC(NULL, hDC);
+ GetFontCellSize(NULL, FontPreview.hFont, &FontPreview.CharHeight, &FontPreview.CharWidth);
/*
* Format:
* Width = FontSize.X = LOWORD(FontSize);
* Height = FontSize.Y = HIWORD(FontSize);
*/
- pConInfo->FontSize.X = (SHORT)(SizeList->UseRasterOrTTList ? CharWidth : 0);
- pConInfo->FontSize.Y = (SHORT)CharHeight;
+ pConInfo->FontSize.X = (SHORT)(SizeList->UseRasterOrTTList ? FontPreview.CharWidth : 0);
+ pConInfo->FontSize.Y = (SHORT)FontPreview.CharHeight;
DPRINT1("pConInfo->FontSize = (%d x %d) ; (CharWidth x CharHeight) = (%d x %d)\n",
- pConInfo->FontSize.X, pConInfo->FontSize.Y, CharWidth, CharHeight);
+ pConInfo->FontSize.X, pConInfo->FontSize.Y,
+ FontPreview.CharWidth, FontPreview.CharHeight);
InvalidateRect(GetDlgItem(hDlg, IDC_STATIC_FONT_WINDOW_PREVIEW), NULL, TRUE);
InvalidateRect(GetDlgItem(hDlg, IDC_STATIC_SELECT_FONT_PREVIEW), NULL, TRUE);
- StringCchPrintfW(szFontSize, ARRAYSIZE(szFontSize), L"%d", CharWidth);
+ StringCchPrintfW(szFontSize, ARRAYSIZE(szFontSize), L"%d", FontPreview.CharWidth);
SetDlgItemText(hDlg, IDC_FONT_SIZE_X, szFontSize);
- StringCchPrintfW(szFontSize, ARRAYSIZE(szFontSize), L"%d", CharHeight);
+ StringCchPrintfW(szFontSize, ARRAYSIZE(szFontSize), L"%d", FontPreview.CharHeight);
SetDlgItemText(hDlg, IDC_FONT_SIZE_Y, szFontSize);
return TRUE;
/* We start with the console client area, rescaled for the preview */
SetRect(&rcWin, 0, 0,
- pConInfo->WindowSize.X * pConInfo->FontSize.X,
- pConInfo->WindowSize.Y * pConInfo->FontSize.Y);
+ pConInfo->WindowSize.X * FontPreview.CharWidth,
+ pConInfo->WindowSize.Y * FontPreview.CharHeight);
RescaleRect(pData, rcWin);
/* Add the scrollbars if needed (does not account for any frame) */
hBrush = CreateSolidBrush(nbkColor);
if (!hBrush) return;
- hOldFont = SelectObject(drawItem->hDC, hCurrentFont);
+ hOldFont = SelectObject(drawItem->hDC, FontPreview.hFont);
//if (hOldFont == NULL)
//{
// DeleteObject(hBrush);
Status = RtlOpenCurrentUser(/*samDesired*/MAXIMUM_ALLOWED, (PHANDLE)&/*CurrentUserKeyHandle*/hKey);
if (!NT_SUCCESS(Status))
{
- DPRINT1("RtlOpenCurrentUser failed, Status = 0x%08lx\n", Status);
+ DPRINT1("RtlOpenCurrentUser() failed, Status = 0x%08lx\n", Status);
SetLastError(RtlNtStatusToDosError(Status));
return FALSE;
}
{
BOOLEAN Success = FALSE;
HKEY hKey;
- DWORD dwNumSubKeys = 0;
+ DWORD dwNumValues = 0;
DWORD dwIndex;
DWORD dwColorIndex = 0;
DWORD dwType;
if (!ConCfgOpenUserSettings(DefaultSettings ? L"" : ConsoleInfo->ConsoleTitle,
&hKey, KEY_READ, FALSE))
{
- DPRINT("ConCfgOpenUserSettings failed\n");
+ DPRINT("ConCfgOpenUserSettings() failed\n");
return FALSE;
}
if (RegQueryInfoKeyW(hKey, NULL, NULL, NULL, NULL, NULL, NULL,
- &dwNumSubKeys, NULL, NULL, NULL, NULL) != ERROR_SUCCESS)
+ &dwNumValues, NULL, NULL, NULL, NULL) != ERROR_SUCCESS)
{
- DPRINT("ConCfgReadUserSettings: RegQueryInfoKeyW failed\n");
+ DPRINT("ConCfgReadUserSettings: RegQueryInfoKeyW() failed\n");
RegCloseKey(hKey);
return FALSE;
}
- DPRINT("ConCfgReadUserSettings entered dwNumSubKeys %d\n", dwNumSubKeys);
+ DPRINT("ConCfgReadUserSettings() entered, dwNumValues %d\n", dwNumValues);
- for (dwIndex = 0; dwIndex < dwNumSubKeys; dwIndex++)
+ for (dwIndex = 0; dwIndex < dwNumValues; dwIndex++)
{
dwValue = sizeof(Value);
dwValueName = ARRAYSIZE(szValueName);
}
else if (!wcscmp(szValueName, L"FaceName"))
{
- StringCchCopyNW(ConsoleInfo->FaceName, ARRAYSIZE(ConsoleInfo->FaceName),
- szValue, ARRAYSIZE(szValue));
+ /* A NULL value means that the defaults should be used instead */
+ if (*szValue)
+ {
+ StringCchCopyNW(ConsoleInfo->FaceName, ARRAYSIZE(ConsoleInfo->FaceName),
+ szValue, ARRAYSIZE(szValue));
+ }
Success = TRUE;
}
else if (!wcscmp(szValueName, L"FontFamily"))
{
- ConsoleInfo->FontFamily = Value;
+ /* A zero value means that the defaults should be used instead */
+ if (Value)
+ ConsoleInfo->FontFamily = Value;
Success = TRUE;
}
else if (!wcscmp(szValueName, L"FontSize"))
{
- ConsoleInfo->FontSize.X = LOWORD(Value); // Width
- ConsoleInfo->FontSize.Y = HIWORD(Value); // Height
+ /* A zero value means that the defaults should be used instead */
+ if (Value)
+ {
+ ConsoleInfo->FontSize.X = LOWORD(Value); // Width
+ ConsoleInfo->FontSize.Y = HIWORD(Value); // Height
+ }
Success = TRUE;
}
else if (!wcscmp(szValueName, L"FontWeight"))
{
- ConsoleInfo->FontWeight = Value;
+ /* A zero value means that the defaults should be used instead */
+ if (Value)
+ ConsoleInfo->FontWeight = Value;
Success = TRUE;
}
else if (!wcscmp(szValueName, L"HistoryBufferSize"))