FNCCHAT - Scroll to bottom

I have this piece of code where I would like to go to the bottom position if new messages have been loaded ( when AScroll = true ) but it doesn't position ...it only shows me a part of the messages ...then as soon as I use the mouse wheel to scroll then the others appear.

How can I “force” the update after loading the new messages ?

I have FNCCHAT 1.0.6.1

thanks

procedure TframeCHAT.LoadConversation( ANumero: string );
begin

     chat.BeginUpdate;

     chat.ChatMessages.Clear;

     MemoryTableReset( mmMSG );

     var AScroll := false;
     try

        AScroll := LoadNewMessage;

     finally

        chat.EndUpdate;

        if AScroll then
           chat.ScrollToBottom;

     end;

end;

Please support ...someone who can help me ?
It's important for me and for my client.

There are 34 message in the list
Clip937

Chat Component show me first 27 message ( also after chat.Endupdate and chat.scrolltobottom )

If I only touch mouse wheel for a tick the components update with the rest of the message

what can I try to do ?
thanks
Alberto

We are currently investigating this, stay tuned.

1 Like

Hi,

The chat messages have a dynamic height by default based on the text inside them. To reduce loading times, only part of the items are calculated beforehand, but this comes with the side effect of not knowing where to scroll exactly. We'll look into the possibility of optionally precalculating all items to resolve this.

Currently, there aren't many options for temporary workarounds. To be able to use ScrollToBottom, you'd need to set the Appearance.Spacing to 0 and the ItemAppearance.HeightMode to tvhmFixed programmatically, but this will result in a look that won't allow any time stamps.

procedure TForm1.FormCreate(Sender: TObject);
begin
  TMSFNCChat1.ItemAppearance.HeightMode := tvhmFixed;
  TMSFNCChat1.Appearance.Spacing := 0;
end;

Alternatively, you can scroll to each message individually to force the calculation but depending on the number of messages, this will likely result in performance issues.

procedure TForm1.Button1Click(Sender: TObject);
var
  I: Integer;
  itm: TTMSFNCChatItem;
begin
  TMSFNCChat1.BeginUpdate;
  try
    TMSFNCChat1.ChatMessages.Clear;
    for I := 0 to 29 do
    begin
      TMSFNCChat1.AddMessage('Message ' + I.ToString);
    end;

  finally
    TMSFNCChat1.EndUpdate;
    for I := 0 to TMSFNCChat1.ChatMessages.Count - 1 do
      TMSFNCChat1.ScrollToItem(I);
  end;
end;

Hi,

Starting from the next version you'll find a new PrecalculateItems property in TTMSFNCChat. If you enable that, all items will be calculated whenever the item list is (re)built allowing ScrollToBottom to function correctly.