We have 23 year old chat program our company and customers use, for Windows only, written in Java, running on a few thousand systems.
Working on an FMX flavor , that will become the mobile version.
A few things I can't figure out if even possible.
When sending images or getting images, it is just a URL to an image from me to them or them to me. How its been for a long time.
Right now it works as i set it to an href link to bring it up in browser. That would be default method.
But.. option wise, I'd like to try and get it to pick up on URLs that have common file extensions, and show a thumbnail image for each image URL in a messag.. and click on it and show a full size image. Assume via some events to do so? Make it like a modern chat app where it auto coverts the img url into thumb nails.
Emojis. We've had a set of our own emote images for these 23 years. It would be nice to have something to implement our own in this.
I see there is a EmojiList object ( not document ) but it appears to be just a string list to convert a text input pattern into a unicode char.
It would be nice to supply a list of text to image list for Emojis.
Notice a bit of a cut off / wrap issue maybe? I added this text for example for a long URL.
this is an image <a href="https://www.example.com/products/electronics/laptops/gaming-laptops/super-gaming-laptop-x-pro-model-2025?color=black&storage=1tbssd&ram=32gb&processor=intel-i9&graphics=rtx4090&affiliate_id=12345&campaign=summer_sale_2025#reviews">https://www.example.com/products/electronics/laptops/gaming-laptops/super-gaming-laptop-x-pro-model-2025?color=black&storage=1tbssd&ram=32gb&processor=intel-i9&graphics=rtx4090&affiliate_id=12345&campaign=summer_sale_2025#reviews</a>
I populate a chat from a history. So if close program and bring up again. I populate the chat box with old chat messages.
I use the Chat.ScrollToBottom; call, but it never scrolls to the very bottom. It always seems to be a few messages from the bottom. ScrollToTop seems to work ok.
Since you mention bringing up the browser, does the href point to an online image? If that is the case then there's no direct built-in solution. Images need to be downloaded (or at least the image data needs to be retrieved) before any kind of thumbnail can be shown. Once you have that, it's a matter of adding an <img> tag between an a <a> tag. <a href="link_to_my_image><img src="image_item"/></a>
You can limit the size by setting the width or height: <img height="100" src="image_item"/>
For the img src you can either use base64 encoded string or an image name from a bitmap container. We strongly suggest using a bitmap container for performance reasons.
It's not a bad idea, something we can put down on our list to investigate. However, you can already implement something similar, but be aware it will modify the text (unless you persist the unmodified text first). You'll need a bitmap container hooked up to the chat component that contains the images for the emojis, then:
procedure TForm3.TMSFNCChat1BeforeSendMessage(Sender: TObject;
var AText: string; var AAllow: Boolean);
begin
//Your text for the heart emoji is ":heart:"
//The emoji name in the bitmap container is "heart"
AText := StringReplace(AText, ':heart:', '<img src="heart"/>', [rfReplaceAll]);
end;
Of course, you'd need to do a replace for all images and do this for all messages (for example, when adding previous messages from earlier).
This affects all of our HTML engine using components, we'll need to investigate. I've put it on our TODO.
Can you provide a small reproducible sample for this? The following works as expected:
procedure TForm3.FormCreate(Sender: TObject);
var
I: Integer;
begin
TMSFNCChat1.BeginUpdate;
TMSFNCChat1.Clear;
for I := 0 to 1000 do
if I mod 2 = 0 then
TMSFNCChat1.AddMessage('Hello ' + i.ToString)
else
TMSFNCChat1.AddMessage('Alternative length message so it has some variety ' + I.ToString);
TMSFNCChat1.EndUpdate;
TMSFNCChat1.ScrollToBottom;
end;
I think i got it figured out maybe.
If I can detect an incoming message text.
Pull out any jpg/png url text i find.
Download the image.
Stick into my bitmap container.
construct a new message text with the html tags needed.
then make my TTMSFNCChatItem with this new text.
I think thats kinda how it works today in the Java program all these years...
As any thing you send over that fits an emote text, gets replaced.
Which causes funny messages with smiley faces images and such in middle of important text.
better HTML is always nice.
Ill get a demo whipped up.
and now
Heres a fun one also.. thumb nail is cut off. Resize form and it then corrects itself.
I ponder if related to #4 ... some height/width calculations getting thrown off?
While not present in my demo app i am working on for you, i find in my much bigger FMX app, that if I have a TTMSFNCChat on the form, the IDE sometimes / often gets very unresponsive to changing things in the object inspector.. taking 5-10 or more seconds to respond. If i delete the TTMSFNCChat object, boom.. instantly IDE is back to normal.
Yes, that should be the flow. Download is needed because the HTML engine is just an HTML rendering engine, it won't have any access to images online.
That's almost inevitable in case of text to image approaches. If we were to implement this, it would not be that much different. From the control's persective a list of text to be replaced with images is going to be just that: a list to check against and replace without much context. Unfortunately we cannot paste an image directly into the edit field as a workaround as TMemo does not support that.
4 & 5: Thank you for the sample, we'll investigate these and report back.
We have not encountered this before so we are unsure how to reproduce. 5-10 seconds sounds too extensive. Maybe it's related to the calculations for redrawing, although it should not be that demanding (unless something continuously triggers a redrawing of the form?). Can you try removing all items from the chat at designtime and see if that makes a difference?
I did that already. I even removed stylebook to make sure not some kind of rendering issue in general ( i hate style book ) but didn't seem to fix anything. I even restarted IDE to make sure. Nothing changed. I haven't been able to figure out how to make a new app to repeat. As this is only so far in an existing app. I will say the form it is in, really isn't all that complex. Some TLayouts, TButton, Tpopup, TLabel and TTMSFNCChat .... when i get time, ill revisit it again and see what I can find. Hard to tell if designer IDE issue in general or designer stuff in the component itself... I am not smart enough to tell who is the culprit here.
Also a feature request.. maybe out of scope. But since this is a chat component.
I am doing my own history saving to a file and loading. Pondering if something could be made internally to handle this? With some events to trigger per item load/save, ect... Maybe way out of scope, but figured i'd ask. As i'm middle of writing this all myself.. and i'd assume others would want to do the same. To emulate modern text messaging / facebook messaging ect like chats.
For 6) can you also try dropping other FNC components on the form to see if it's just the chat or FNC in general? Perhaps TTMSFNCSwitch which is completely unrelated and has no items. If that is not causing any issues then TTMSFNCTableView could be an interesting one to check too as TTMSFNCChat builds on top of it.
We'll add it to the list and discuss internally. Do you have a specific format in mind for the file?
I know I have some FNC buttons and other simple controls else where and no problems I can tell.
Format wise? Probably something JSON based? I assume if do go this route, ability to run it through encryption process in and out if someone doesn't want it plain text.