From 922c2ab8bb6dc1cc2664f2572c9d62951178ff33 Mon Sep 17 00:00:00 2001 From: maxim Date: Thu, 28 May 2015 20:19:27 +0000 Subject: [PATCH] Merged revision(s) 49170 #8077f55310 from trunk: LCL-Win: Prevent flicker in TListbox. Issue #28146, patch from wp. ........ git-svn-id: branches/fixes_1_4@49198 - --- lcl/interfaces/win32/win32wsstdctrls.pp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lcl/interfaces/win32/win32wsstdctrls.pp b/lcl/interfaces/win32/win32wsstdctrls.pp index 42e54761ec..d28d7462ad 100644 --- a/lcl/interfaces/win32/win32wsstdctrls.pp +++ b/lcl/interfaces/win32/win32wsstdctrls.pp @@ -583,6 +583,9 @@ var WindowInfo: PWin32WindowInfo; NCCreateParams: PNCCreateParams; LMessage: TLMessage; + Count: LResult; + Top: Integer; + ARect: TRect; begin case Msg of WM_NCCREATE: @@ -609,6 +612,26 @@ begin LMessage.Result := 0; Exit(DeliverMessage(WindowInfo^.WinControl, LMessage)); end; + WM_ERASEBKGND: + // Avoid unnecessary background paints to avoid flickering of the listbox + begin + WindowInfo := GetWin32WindowInfo(Window); + Count := SendMessage(Window, LB_GETCOUNT, 0, 0); + if Assigned(WindowInfo^.WinControl) and + (TCustomListBox(WindowInfo^.WinControl).Columns < 2) and + (Count <> LB_ERR) and (SendMessage(Window, LB_GETITEMRECT, Count - 1, Windows.LParam(@ARect)) <> LB_ERR) then + begin + Top := ARect.Bottom; + Windows.GetClientRect(Window, ARect); + ARect.Top := Top; + if not IsRectEmpty(ARect) then + Windows.FillRect(HDC(WParam), ARect, WindowInfo^.WinControl.Brush.Reference.Handle); + Result := 1; + end + else + Result := CallDefaultWindowProc(Window, Msg, WParam, LParam); + Exit; + end; end; // normal processing Result := WindowProc(Window, Msg, WParam, LParam);