Cache background color brush instead of recreating it at each screen update.
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index 2dfd581..a25a90d 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c
@@ -821,6 +821,7 @@ ed->nUDArrowX = -1; ed->nSequence = 0; ed->rgbBackColor = -1; + ed->hbrBackground = GetSysColorBrush(COLOR_WINDOW); ed->bCaretAtEnd = FALSE; ed->nEventMask = 0; ed->nModifyStep = 0; @@ -926,7 +927,8 @@ if (editor->pFontCache[i].hFont) DeleteObject(editor->pFontCache[i].hFont); } - + DeleteObject(editor->hbrBackground); + FREE_OBJ(editor); } @@ -1265,10 +1267,18 @@ case EM_SETBKGNDCOLOR: { LRESULT lColor = ME_GetBackColor(editor); + if (editor->rgbBackColor != -1) + DeleteObject(editor->hbrBackground); if (wParam) + { editor->rgbBackColor = -1; + editor->hbrBackground = GetSysColorBrush(COLOR_WINDOW); + } else + { editor->rgbBackColor = lParam; + editor->hbrBackground = CreateSolidBrush(editor->rgbBackColor); + } if (editor->bRedraw) { InvalidateRect(hWnd, NULL, TRUE); @@ -1792,12 +1802,9 @@ { HDC hDC = (HDC)wParam; RECT rc; - COLORREF rgbBG = ME_GetBackColor(editor); if (GetUpdateRect(hWnd,&rc,TRUE)) { - HBRUSH hbr = CreateSolidBrush(rgbBG); - FillRect(hDC, &rc, hbr); - DeleteObject(hbr); + FillRect(hDC, &rc, editor->hbrBackground); } } return 1;
diff --git a/dlls/riched20/editstr.h b/dlls/riched20/editstr.h index 2e8f175..7a7398f 100644 --- a/dlls/riched20/editstr.h +++ b/dlls/riched20/editstr.h
@@ -270,6 +270,7 @@ int nSequence; int nOldSelFrom, nOldSelTo; COLORREF rgbBackColor; + HBRUSH hbrBackground; BOOL bCaretAtEnd; int nEventMask; int nModifyStep;
diff --git a/dlls/riched20/paint.c b/dlls/riched20/paint.c index 29420c6..e1c56b4 100644 --- a/dlls/riched20/paint.c +++ b/dlls/riched20/paint.c
@@ -78,14 +78,11 @@ } if (ye>ys) { - HBRUSH hbr; - hbr = CreateSolidBrush(ME_GetBackColor(c.editor)); rc.left = xs; rc.top = ys; rc.right = xe; rc.bottom = ye; - FillRect(hDC, &rc, hbr); - DeleteObject(hbr); + FillRect(hDC, &rc, c.editor->hbrBackground); } if (ys == c.pt.y) /* don't overwrite the top bar */ ys++;