diff --git a/components/richmemo/win32/win32richmemo.pas b/components/richmemo/win32/win32richmemo.pas index 4f8564535..d177e576f 100644 --- a/components/richmemo/win32/win32richmemo.pas +++ b/components/richmemo/win32/win32richmemo.pas @@ -300,6 +300,11 @@ begin if Assigned(AWinControl) and (AWinControl is TCustomRichMemo) then TIntCustomRichMemo(AWinControl).Change; Result:=true; + if IsIconic( GetAncestor(AWinControl.Handle, GA_ROOTOWNER)) then + // hack: the RichMemo has problems repainting itself + // if changes were done while the root window was minimized + // see #34391 + GetWin32WindowInfo(AWinControl.Handle)^.TrackValid:=true; end; end; end; @@ -347,13 +352,28 @@ function RichEditProc(Window: HWnd; Msg: UInt; WParam: Windows.WParam; var WindowInfo : PWin32WindowInfo; NcHandled : Boolean; // NCPaint has painted by itself + r: TRect; + PrevWndProc: Windows.WNDPROC; begin case Msg of WM_PAINT : begin //todo: LCL WM_PAINT handling prevents richedit from drawing correctly - Result := CallDefaultWindowProc(Window, Msg, WParam, LParam) + Result := CallDefaultWindowProc(Window, Msg, WParam, LParam); //Result := WindowProc(Window, Msg, WParam, LParam) + // hack: the RichMemo has problems repainting itself + // if changes were done while the root window was minimized + // see #34391 + if GetWin32WindowInfo(Window)^.TrackValid then begin + Windows.GetWindowRect(Window, r); + OffsetRect(r, -r.left, -r.top); + r.Left:=-r.Right; + r.Top:=-r.Bottom; + InvalidateRect(Window, @r, false); + PrevWndProc := GetWin32WindowInfo(Window)^.DefWndProc; + Windows.CallWindowProcW(PrevWndProc, Window, Msg, WParam, LParam); + GetWin32WindowInfo(Window)^.TrackValid:=false; end; + end; //When theming is enabled, and the component should have a border around it, WM_NCPAINT: begin if Assigned(NCPaint) then begin