ChatBox

TsgcHTMLComponent_ChatBox — una caja de burbujas de chat estilo tarjeta con mensajes a izquierda/derecha, avatares, una barra de entrada y un indicador de escritura animado, en Delphi, C++ Builder y .NET.

TsgcHTMLComponent_ChatBox

Un componente de chat ligero que emite una card de Bootstrap 5 con burbujas de mensajes desplazables y una barra de entrada opcional. Añade mensajes, define unas pocas propiedades y luego lee la propiedad HTML.

Clase de componente

TsgcHTMLComponent_ChatBox

Renderiza

card de Bootstrap 5 + CSS con ámbito

Familia

Chat e IA

Lenguajes

Delphi, C++ Builder, .NET

Créalo, añade mensajes, renderízalo

Define Title y Height, envía unos cuantos mensajes con AddMessage (eligiendo caLeft o caRight) y luego lee HTML (o insértalo en una página TsgcHTMLTemplate_Bootstrap).

uses
  sgcHTML_Enums, sgcHTML_Component_ChatBox;

var
  oChat: TsgcHTMLComponent_ChatBox;
begin
  oChat := TsgcHTMLComponent_ChatBox.Create(nil);
  try
    oChat.Title := 'Support';
    oChat.Height := '400px';
    oChat.ShowInput := True;
    oChat.InputPlaceholder := 'Type a message...';
    oChat.ShowTypingIndicator := True;

    oChat.AddMessage('Alice', 'Hi, how can I help?', caLeft, hcSecondary);
    oChat.AddMessage('You', 'My order has not arrived.', caRight, hcPrimary);

    WebModule.Response := oChat.HTML;   // Bootstrap card + chat bubbles
  finally
    oChat.Free;
  end;
end;

// Append a single new bubble (e.g. over a WebSocket push):
oChat.AddMessage('Alice', 'Let me check that for you.', caLeft);
WebSocket.WriteData(oChat.GetLastMessageHTML);
// includes: sgcHTML_Enums.hpp, sgcHTML_Component_ChatBox.hpp

TsgcHTMLComponent_ChatBox *oChat = new TsgcHTMLComponent_ChatBox(NULL);
try
{
  oChat->Title = "Support";
  oChat->Height = "400px";
  oChat->ShowInput = true;
  oChat->InputPlaceholder = "Type a message...";
  oChat->ShowTypingIndicator = true;

  oChat->AddMessage("Alice", "Hi, how can I help?", caLeft, hcSecondary);
  oChat->AddMessage("You", "My order has not arrived.", caRight, hcPrimary);

  String html = oChat->HTML;   // Bootstrap card + chat bubbles
}
__finally
{
  delete oChat;
}
using esegece.sgcWebSockets;

var chat = new TsgcHTMLComponent_ChatBox();
chat.Title = "Support";
chat.Height = "400px";
chat.ShowInput = true;
chat.InputPlaceholder = "Type a message...";
chat.ShowTypingIndicator = true;

chat.AddMessage("Alice", "Hi, how can I help?", TsgcHTMLChatAlign.caLeft, TsgcHTMLColor.hcSecondary);
chat.AddMessage("You", "My order has not arrived.", TsgcHTMLChatAlign.caRight, TsgcHTMLColor.hcPrimary);

string html = chat.HTML;   // Bootstrap card + chat bubbles

Propiedades y métodos clave

Los miembros que más vas a usar.

Mensajes

Messages es una colección TsgcHTMLChatMessages; cada TsgcHTMLChatMessage lleva Sender, Text, Timestamp, Align (caLeft/caRight), Color y AvatarInitials.

Añadir un mensaje

AddMessage(aSender, aText, aAlign, aColor, aTimestamp) añade una burbuja; las iniciales del avatar y la hora se rellenan por ti cuando se omiten.

Barra de entrada

ShowInput activa o desactiva el formulario; InputPlaceholder, SendButtonText y SendButtonStyle (un TsgcHTMLButtonStyle) controlan el redactor.

Cabecera y escritura

Title define la cabecera de la tarjeta; ShowTypingIndicator muestra los puntos animados y TypingText define su etiqueta.

Identidad y tamaño

ChatID nombra los ids de los elementos; Height acota el área de desplazamiento (se desplaza automáticamente al mensaje más reciente).

Salida

HTML devuelve la tarjeta completa; GetLastMessageHTML devuelve solo la burbuja más reciente — ideal para enviar una única actualización por un WebSocket.

Sigue explorando

Todos los componentes sgcHTMLExplora la matriz completa de más de 60 componentes.
Descargar prueba gratuitaLa prueba de 30 días incluye los proyectos demo 60.HTML.
PreciosLicencias Single, Team y Site con código fuente completo.

¿Listo para empezar?

Descarga la prueba gratuita y empieza a crear interfaces web en Delphi, C++ Builder y .NET.