diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index 158917331f5..518f86b5e2c 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -1284,7 +1284,8 @@ void ME_DestroyEditor(ME_TextEditor *editor) if (editor->pFontCache[i].hFont) DeleteObject(editor->pFontCache[i].hFont); } - DeleteObject(editor->hbrBackground); + if (editor->rgbBackColor != -1) + DeleteObject(editor->hbrBackground); if(editor->lpOleCallback) IUnknown_Release(editor->lpOleCallback); @@ -1732,9 +1733,13 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam, } case EM_SETBKGNDCOLOR: { - LRESULT lColor = ME_GetBackColor(editor); - if (editor->rgbBackColor != -1) + LRESULT lColor; + if (editor->rgbBackColor != -1) { DeleteObject(editor->hbrBackground); + lColor = editor->rgbBackColor; + } + else lColor = GetSysColor(COLOR_WINDOW); + if (wParam) { editor->rgbBackColor = -1; diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h index 8757e456326..5cb9b7e7f40 100644 --- a/dlls/riched20/editor.h +++ b/dlls/riched20/editor.h @@ -239,7 +239,6 @@ void ME_RewrapRepaint(ME_TextEditor *editor); void ME_UpdateRepaint(ME_TextEditor *editor); void ME_DrawParagraph(ME_Context *c, ME_DisplayItem *paragraph); void ME_EnsureVisible(ME_TextEditor *editor, ME_DisplayItem *pRun); -COLORREF ME_GetBackColor(const ME_TextEditor *editor); void ME_InvalidateSelection(ME_TextEditor *editor); void ME_QueueInvalidateFromCursor(ME_TextEditor *editor, int nCursor); BOOL ME_SetZoom(ME_TextEditor *editor, int numerator, int denominator); diff --git a/dlls/riched20/paint.c b/dlls/riched20/paint.c index 84ab695a382..b21e5bc22d9 100644 --- a/dlls/riched20/paint.c +++ b/dlls/riched20/paint.c @@ -146,13 +146,12 @@ static void ME_DrawTextWithStyle(ME_Context *c, int x, int y, LPCWSTR szText, in ME_Style *s, int *width, int nSelFrom, int nSelTo, int ymin, int cy) { HDC hDC = c->hDC; HGDIOBJ hOldFont; - COLORREF rgbOld, rgbBack; + COLORREF rgbOld; int yOffset = 0, yTwipsOffset = 0; SIZE sz; COLORREF rgb; hOldFont = ME_SelectStyleFont(c->editor, hDC, s); - rgbBack = ME_GetBackColor(c->editor); if ((s->fmt.dwMask & CFM_LINK) && (s->fmt.dwEffects & CFE_LINK)) rgb = RGB(0,0,255); else if ((s->fmt.dwMask & CFM_COLOR) && (s->fmt.dwEffects & CFE_AUTOCOLOR)) @@ -309,17 +308,6 @@ static void ME_DrawRun(ME_Context *c, int x, int y, ME_DisplayItem *rundi, ME_Pa } } -COLORREF ME_GetBackColor(const ME_TextEditor *editor) -{ -/* Looks like I was seriously confused - return GetSysColor((GetWindowLong(editor->hWnd, GWL_STYLE) & ES_READONLY) ? COLOR_3DFACE: COLOR_WINDOW); -*/ - if (editor->rgbBackColor == -1) - return GetSysColor(COLOR_WINDOW); - else - return editor->rgbBackColor; -} - void ME_DrawParagraph(ME_Context *c, ME_DisplayItem *paragraph) { int align = SetTextAlign(c->hDC, TA_BASELINE); ME_DisplayItem *p; @@ -350,22 +338,19 @@ void ME_DrawParagraph(ME_Context *c, ME_DisplayItem *paragraph) { rcPara.bottom = y+p->member.row.nHeight; visible = RectVisible(c->hDC, &rcPara); if (visible) { - HBRUSH hbr; - hbr = CreateSolidBrush(ME_GetBackColor(c->editor)); /* left margin */ rc.left = c->rcView.left; rc.right = c->rcView.left+nMargWidth; rc.top = y; rc.bottom = y+p->member.row.nHeight; - FillRect(c->hDC, &rc, hbr/* c->hbrMargin */); + FillRect(c->hDC, &rc, c->editor->hbrBackground); /* right margin */ rc.left = xe; rc.right = c->rcView.right; - FillRect(c->hDC, &rc, hbr/* c->hbrMargin */); + FillRect(c->hDC, &rc, c->editor->hbrBackground); rc.left = c->rcView.left+nMargWidth; rc.right = xe; - FillRect(c->hDC, &rc, hbr); - DeleteObject(hbr); + FillRect(c->hDC, &rc, c->editor->hbrBackground); } if (me_debug) {