Toast

TsgcHTMLComponent_Toast — renderizza una notifica toast Bootstrap 5 con titolo, corpo, timestamp, colore e occultamento automatico, collocata sullo schermo da un contenitore posizionato, in Delphi, C++ Builder e .NET.

TsgcHTMLComponent_Toast

Un componente toast che emette markup toast Bootstrap 5. Imposta il titolo, il corpo e il colore, quindi leggi la proprietà HTML — oppure chiama l’helper statico Build e racchiudi i toast in un BuildContainer posizionato.

Classe del componente

TsgcHTMLComponent_Toast

Renderizza

Bootstrap 5 toast markup

Linguaggi

Delphi, C++ Builder, .NET

Costruiscilo in una riga, o configuralo completamente

Chiama Build(title, body, color, timestamp) per un toast rapido e racchiudilo in BuildContainer(toasts, position), oppure crea il componente, imposta AutoHide e Delay, quindi leggi HTML.

uses
  sgcHTML_Enums, sgcHTML_Component_Toast;

// One-line static helper (primary form):
var
  vToast: string;
begin
  vToast := TsgcHTMLComponent_Toast.Build('Saved',
    'Your changes were stored.', hcSuccess, 'just now');
  WebModule.Response := TsgcHTMLComponent_Toast.BuildContainer(vToast,
    tpTopEnd);
end;

// Or configure it fully:
var
  oToast: TsgcHTMLComponent_Toast;
begin
  oToast := TsgcHTMLComponent_Toast.Create(nil);
  try
    oToast.ToastID := 'saveToast';
    oToast.Title := 'Saved';
    oToast.Body := 'Your changes were stored.';
    oToast.ColorStyle := hcSuccess;
    oToast.Timestamp := 'just now';
    oToast.AutoHide := True;
    oToast.Delay := 4000;

    WebModule.Response := oToast.HTML;   // Bootstrap toast markup
  finally
    oToast.Free;
  end;
end;
// includes: sgcHTML_Enums.hpp, sgcHTML_Component_Toast.hpp

// One-line static helper (primary form):
String toast = TsgcHTMLComponent_Toast::Build("Saved",
  "Your changes were stored.", hcSuccess, "just now");
String html = TsgcHTMLComponent_Toast::BuildContainer(toast, tpTopEnd);

// Or configure it fully:
TsgcHTMLComponent_Toast *oToast = new TsgcHTMLComponent_Toast(NULL);
try
{
  oToast->ToastID = "saveToast";
  oToast->Title = "Saved";
  oToast->Body = "Your changes were stored.";
  oToast->ColorStyle = hcSuccess;
  oToast->Timestamp = "just now";
  oToast->AutoHide = true;
  oToast->Delay = 4000;

  String body = oToast->HTML;   // Bootstrap toast markup
}
__finally
{
  delete oToast;
}
using esegece.sgcWebSockets;

// One-line static helper (primary form):
string toast = TsgcHTMLComponent_Toast.Build("Saved",
    "Your changes were stored.", TsgcHTMLColor.hcSuccess, "just now");
string html = TsgcHTMLComponent_Toast.BuildContainer(toast,
    TsgcHTMLToastPosition.tpTopEnd);

// Or configure it fully:
var t = new TsgcHTMLComponent_Toast();
t.ToastID = "saveToast";
t.Title = "Saved";
t.Body = "Your changes were stored.";
t.ColorStyle = TsgcHTMLColor.hcSuccess;
t.Timestamp = "just now";
t.AutoHide = true;
t.Delay = 4000;

string body = t.HTML;   // Bootstrap toast markup

Proprietà e metodi principali

I membri che utilizzerai più spesso.

Contenuto

Title imposta il testo dell’intestazione, Body il messaggio, Timestamp la piccola etichetta dell’ora e Icon un’icona inline prima del titolo.

Colore

ColorStyle accetta un TsgcHTMLColor (come hcSuccess o hcDanger); Color accetta una stringa grezza con il nome di un colore Bootstrap.

Occultamento automatico

AutoHide chiude il toast automaticamente dopo Delay millisecondi (predefinito 5000); imposta AutoHide a False per mantenerlo fisso.

Identità

ToastID assegna l’id dell’elemento così puoi mostrare o nascondere un toast specifico da JavaScript.

Helper statici

Build(title, body, color, timestamp) restituisce un toast; BuildContainer(toasts, position) li racchiude in un toast-container fisso (TsgcHTMLToastPosition).

Output

HTML restituisce il markup completo del toast Bootstrap — servilo, oppure assegnalo al BodyContent di un template di pagina.

Continua a esplorare

Tutti i componenti sgcHTMLEsplora la matrice completa delle funzionalità di oltre 60 componenti.
Scarica la Prova GratuitaLa prova di 30 giorni include i progetti demo 60.HTML.
PrezziLicenze Single, Team e Site con codice sorgente completo.

Pronto a Iniziare?

Scarica la versione di prova gratuita e inizia a creare interfacce web in Delphi, C++ Builder e .NET.