mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 06:22:58 +00:00
[CONSOLE.CPL] Use fallback brushes for text preview in case CreateSolidBrush() fails (e.g. low memory scenario).
This commit is contained in:
parent
0e5496d082
commit
13b3425369
2 changed files with 10 additions and 15 deletions
|
@ -26,10 +26,8 @@ PaintStaticControls(
|
||||||
ARRAYSIZE(pConInfo->ColorTable) - 1);
|
ARRAYSIZE(pConInfo->ColorTable) - 1);
|
||||||
|
|
||||||
hBrush = CreateSolidBrush(pConInfo->ColorTable[index]);
|
hBrush = CreateSolidBrush(pConInfo->ColorTable[index]);
|
||||||
if (!hBrush) return;
|
FillRect(drawItem->hDC, &drawItem->rcItem, hBrush ? hBrush : GetStockObject(BLACK_BRUSH));
|
||||||
|
if (hBrush) DeleteObject(hBrush);
|
||||||
FillRect(drawItem->hDC, &drawItem->rcItem, hBrush);
|
|
||||||
DeleteObject(hBrush);
|
|
||||||
|
|
||||||
if (ActiveStaticControl == index)
|
if (ActiveStaticControl == index)
|
||||||
DrawFocusRect(drawItem->hDC, &drawItem->rcItem);
|
DrawFocusRect(drawItem->hDC, &drawItem->rcItem);
|
||||||
|
|
|
@ -390,8 +390,8 @@ WinPrev_OnDraw(
|
||||||
|
|
||||||
/* Draw the console background */
|
/* Draw the console background */
|
||||||
hBrush = CreateSolidBrush(pConInfo->ColorTable[BkgdAttribFromAttrib(pConInfo->ScreenAttributes)]);
|
hBrush = CreateSolidBrush(pConInfo->ColorTable[BkgdAttribFromAttrib(pConInfo->ScreenAttributes)]);
|
||||||
FillRect(hDC, &rcWin, hBrush);
|
FillRect(hDC, &rcWin, hBrush ? hBrush : GetStockObject(BLACK_BRUSH));
|
||||||
DeleteObject(hBrush);
|
if (hBrush) DeleteObject(hBrush);
|
||||||
}
|
}
|
||||||
|
|
||||||
static LRESULT CALLBACK
|
static LRESULT CALLBACK
|
||||||
|
@ -489,20 +489,18 @@ PaintText(
|
||||||
nbkColor = pConInfo->ColorTable[BkgdAttribFromAttrib(CurrentAttrib)];
|
nbkColor = pConInfo->ColorTable[BkgdAttribFromAttrib(CurrentAttrib)];
|
||||||
ntColor = pConInfo->ColorTable[TextAttribFromAttrib(CurrentAttrib)];
|
ntColor = pConInfo->ColorTable[TextAttribFromAttrib(CurrentAttrib)];
|
||||||
|
|
||||||
|
/* Draw the console background */
|
||||||
hBrush = CreateSolidBrush(nbkColor);
|
hBrush = CreateSolidBrush(nbkColor);
|
||||||
if (!hBrush) return;
|
FillRect(drawItem->hDC, &drawItem->rcItem, hBrush ? hBrush : GetStockObject(BLACK_BRUSH));
|
||||||
|
if (hBrush) DeleteObject(hBrush);
|
||||||
|
|
||||||
|
/* Refresh the font preview, getting a new font if necessary */
|
||||||
if (FontPreview.hFont == NULL)
|
if (FontPreview.hFont == NULL)
|
||||||
RefreshFontPreview(&FontPreview, pConInfo);
|
RefreshFontPreview(&FontPreview, pConInfo);
|
||||||
|
|
||||||
|
/* Draw the preview text using the current font */
|
||||||
hOldFont = SelectObject(drawItem->hDC, FontPreview.hFont);
|
hOldFont = SelectObject(drawItem->hDC, FontPreview.hFont);
|
||||||
//if (hOldFont == NULL)
|
// if (!hOldFont) return;
|
||||||
//{
|
|
||||||
// DeleteObject(hBrush);
|
|
||||||
// return;
|
|
||||||
//}
|
|
||||||
|
|
||||||
FillRect(drawItem->hDC, &drawItem->rcItem, hBrush);
|
|
||||||
|
|
||||||
/* Add a few space between the preview window border and the text sample */
|
/* Add a few space between the preview window border and the text sample */
|
||||||
InflateRect(&drawItem->rcItem, -2, -2);
|
InflateRect(&drawItem->rcItem, -2, -2);
|
||||||
|
@ -514,7 +512,6 @@ PaintText(
|
||||||
SetBkColor(drawItem->hDC, pbkColor);
|
SetBkColor(drawItem->hDC, pbkColor);
|
||||||
|
|
||||||
SelectObject(drawItem->hDC, hOldFont);
|
SelectObject(drawItem->hDC, hOldFont);
|
||||||
DeleteObject(hBrush);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue