From 702b39768f5682321fa1b19b81417702e3452891 Mon Sep 17 00:00:00 2001
From: the-Arioch <the_Arioch@nm.ru>
Date: Fri, 6 Sep 2013 20:36:22 +0400
Subject: [PATCH] #6191: inter-items outline was lost when changing the
 TJvListBox.Items.Text

---
 jvcl/run/JvListBox.pas | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/jvcl/run/JvListBox.pas b/jvcl/run/JvListBox.pas
index 2daeb34..b29a60d 100644
--- a/jvcl/run/JvListBox.pas
+++ b/jvcl/run/JvListBox.pas
@@ -2343,16 +2343,28 @@ procedure TJvCustomListBox.WndProc(var Msg: TMessage);
 var
   ItemWidth: Word;
 begin
+//TODO:  Three of five messages below have later worked out in
+//
+//    procedure LBAddString(var Msg: TMessage); message LB_ADDSTRING;
+//    procedure LBInsertString(var Msg: TMessage); message LB_INSERTSTRING;
+//    procedure LBDeleteString(var Msg: TMessage); message LB_DELETESTRING;
+//
+//    Either that is intended (to make pre- and post-processing around stock
+//      VCL.TListBox behavior), then it should be documented.
+//    Or that is naive merging artefact and should be fixed (single responsibnility principle)
   case Msg.Msg of
     LB_ADDSTRING, LB_INSERTSTRING:
       begin
+        FItemsHeightValid := False;
         ItemWidth := Canvas.TextWidth(StrPas(PChar(Msg.LParam)) + ' ');
         if FMaxWidth < ItemWidth then
           FMaxWidth := ItemWidth;
-        SendMessage(Handle, LB_SETHORIZONTALEXTENT, FMaxWidth, 0);
+        if ScrollBars in [ssBoth, ssHorizontal] then
+           SendMessage(Handle, LB_SETHORIZONTALEXTENT, FMaxWidth, 0);
       end;
     LB_DELETESTRING:
       begin
+        FItemsHeightValid := False;
         if Msg.WParam < WPARAM(ItemsShowing.Count) then
           ItemWidth := Canvas.TextWidth(ItemsShowing[Msg.WParam] + ' ')
         else
@@ -2365,9 +2377,13 @@ begin
         end;
       end;
     LB_RESETCONTENT:
-      SendMessage(Handle, LB_SETHORIZONTALEXTENT, 0, 0);
+      begin
+        FItemsHeightValid := False;
+        SendMessage(Handle, LB_SETHORIZONTALEXTENT, 0, 0);
+      end;
     WM_SETFONT:
       begin
+        FItemsHeightValid := False;
         inherited WndProc(Msg);
         Canvas.Font.Assign(Font);
         UpdateHorizontalExtent;
-- 
1.8.3.msysgit.0

