Toast

TsgcHTMLComponent_Toast — erzeugen Sie eine Bootstrap-5-Toast-Benachrichtigung mit Titel, Inhalt, Zeitstempel, Farbe und Auto-Ausblenden, auf dem Bildschirm platziert durch einen positionierten Container, in Delphi, C++ Builder und .NET.

TsgcHTMLComponent_Toast

Eine Toast-Komponente, die Bootstrap-5-toast-Markup ausgibt. Setzen Sie Titel, Inhalt und Farbe und lesen Sie dann die HTML-Eigenschaft — oder rufen Sie den statischen Build-Helfer auf und umschließen Sie Toasts in einem positionierten BuildContainer.

Komponentenklasse

TsgcHTMLComponent_Toast

Rendert

Bootstrap-5-Toast-Markup

Sprachen

Delphi, C++ Builder, .NET

In einer Zeile erstellen oder vollständig konfigurieren

Rufen Sie Build(title, body, color, timestamp) für einen schnellen Toast auf und umschließen Sie ihn in BuildContainer(toasts, position), oder erstellen Sie die Komponente, setzen Sie AutoHide und Delay und lesen Sie dann 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

Wichtige Eigenschaften & Methoden

Die Member, die Sie am häufigsten verwenden.

Inhalt

Title setzt den Kopfzeilentext, Body die Nachricht, Timestamp die kleine Zeitbeschriftung und Icon ein Inline-Icon vor dem Titel.

Farbe

ColorStyle nimmt einen TsgcHTMLColor (wie hcSuccess oder hcDanger); Color akzeptiert eine rohe Bootstrap-Farbnamen-Zeichenkette.

Auto-Ausblenden

AutoHide blendet den Toast nach Delay Millisekunden (Standard 5000) automatisch aus; setzen Sie AutoHide auf False, um ihn fixiert zu halten.

Identität

ToastID weist die Element-id zu, sodass Sie einen bestimmten Toast aus JavaScript ein- oder ausblenden können.

Statische Helfer

Build(title, body, color, timestamp) gibt einen Toast zurück; BuildContainer(toasts, position) umschließt sie in einem festen toast-container (TsgcHTMLToastPosition).

Ausgabe

HTML gibt das vollständige Bootstrap-Toast-Markup zurück — liefern Sie es aus oder weisen Sie es dem BodyContent einer Seitenvorlage zu.

Weiter entdecken

Alle sgcHTML-KomponentenDurchsuchen Sie die vollständige Funktionsmatrix von über 60 Komponenten.
Kostenlose Testversion herunterladenDie 30-Tage-Testversion enthält die 60.HTML-Demoprojekte.
PreiseSingle-, Team- und Site-Lizenzen mit vollständigem Quellcode.

Bereit loszulegen?

Laden Sie die kostenlose Testversion herunter und beginnen Sie, Web-UIs in Delphi, C++ Builder und .NET zu erstellen.