Modal

TsgcHTMLComponent_Modal — renderuje modalne okno dialogowe Bootstrap 5 z tytułem, treścią, przyciskami stopki, rozmiarem oraz wyśrodkowanym lub statycznym tłem, w Delphi, C++ Builder i .NET.

TsgcHTMLComponent_Modal

Komponent modalnego okna dialogowego, który generuje znaczniki modal Bootstrap 5. Ustaw tytuł, treść i rozmiar, dodaj przyciski stopki, a następnie odczytaj właściwość HTML — albo wywołaj statyczną metodę pomocniczą Build dla jednolinijkowca.

Klasa komponentu

TsgcHTMLComponent_Modal

Renderuje

Znaczniki modal Bootstrap 5

Języki

Delphi, C++ Builder, .NET

Zbuduj go w jednej linii lub skonfiguruj w pełni

Wywołaj Build(id, title, body, footer, size) dla szybkiego okna modalnego albo utwórz komponent, dodaj przyciski stopki za pomocą AddFooterButton, a następnie odczytaj HTML. Połącz go z BuildTriggerButton, aby otworzyć okno dialogowe.

uses
  sgcHTML_Enums, sgcHTML_Component_Modal;

// One-line static helper (primary form):
var
  vTrigger, vDialog: string;
begin
  vTrigger := TsgcHTMLComponent_Modal.BuildTriggerButton('confirmModal',
    'Delete account', bsDanger);
  vDialog := TsgcHTMLComponent_Modal.Build('confirmModal',
    'Please confirm', 'This action cannot be undone.',
    '', msDefault);
  WebModule.Response := vTrigger + vDialog;
end;

// Or configure it fully and add custom footer buttons:
var
  oModal: TsgcHTMLComponent_Modal;
begin
  oModal := TsgcHTMLComponent_Modal.Create(nil);
  try
    oModal.ModalID := 'confirmModal';
    oModal.Title := 'Please confirm';
    oModal.Body := 'This action cannot be undone.';
    oModal.Size := msLarge;
    oModal.Centered := True;
    oModal.StaticBackdrop := True;

    oModal.AddFooterButton('Cancel', bsSecondary, True);
    oModal.AddFooterButton('Delete', bsDanger);

    WebModule.Response := oModal.HTML;   // Bootstrap modal markup
  finally
    oModal.Free;
  end;
end;
// includes: sgcHTML_Enums.hpp, sgcHTML_Component_Modal.hpp

// One-line static helper (primary form):
String trigger = TsgcHTMLComponent_Modal::BuildTriggerButton("confirmModal",
  "Delete account", bsDanger);
String dialog = TsgcHTMLComponent_Modal::Build("confirmModal",
  "Please confirm", "This action cannot be undone.",
  "", msDefault);

// Or configure it fully and add custom footer buttons:
TsgcHTMLComponent_Modal *oModal = new TsgcHTMLComponent_Modal(NULL);
try
{
  oModal->ModalID = "confirmModal";
  oModal->Title = "Please confirm";
  oModal->Body = "This action cannot be undone.";
  oModal->Size = msLarge;
  oModal->Centered = true;
  oModal->StaticBackdrop = true;

  oModal->AddFooterButton("Cancel", bsSecondary, true);
  oModal->AddFooterButton("Delete", bsDanger);

  String html = oModal->HTML;   // Bootstrap modal markup
}
__finally
{
  delete oModal;
}
using esegece.sgcWebSockets;

// One-line static helper (primary form):
string trigger = TsgcHTMLComponent_Modal.BuildTriggerButton("confirmModal",
    "Delete account", TsgcHTMLButtonStyle.bsDanger);
string dialog = TsgcHTMLComponent_Modal.Build("confirmModal",
    "Please confirm", "This action cannot be undone.",
    "", TsgcHTMLModalSize.msDefault);

// Or configure it fully and add custom footer buttons:
var modal = new TsgcHTMLComponent_Modal();
modal.ModalID = "confirmModal";
modal.Title = "Please confirm";
modal.Body = "This action cannot be undone.";
modal.Size = TsgcHTMLModalSize.msLarge;
modal.Centered = true;
modal.StaticBackdrop = true;

modal.AddFooterButton("Cancel", TsgcHTMLButtonStyle.bsSecondary, true);
modal.AddFooterButton("Delete", TsgcHTMLButtonStyle.bsDanger);

string html = modal.HTML;   // Bootstrap modal markup

Kluczowe właściwości i metody

Składniki, po które sięgasz najczęściej.

Treść

Title ustawia nagłówek, Body przechowuje treść okna dialogowego, a Footer przyjmuje surowy HTML stopki; ModalID to identyfikator elementu używany przez wyzwalacze.

Przyciski stopki

AddFooterButton(text, style, closeOnClick) dołącza stylizowany przycisk; przekaż True dla closeOnClick, aby zamknąć okno modalne po kliknięciu.

Rozmiar

Size wybiera msDefault, msSmall, msLarge, msXLarge lub msFullscreen za pomocą TsgcHTMLModalSize.

Zachowanie

Centered wyśrodkowuje okno dialogowe w pionie, Scrollable przewija długą treść, StaticBackdrop blokuje zamknięcie po kliknięciu poza oknem, a ShowClose przełącza X w nagłówku.

Metody pomocnicze

Build(id, title, body, footer, size) zwraca gotowe okno modalne; BuildTriggerButton(modalID, text, style) generuje przycisk, który je otwiera.

Wynik

HTML zwraca kompletne znaczniki okna modalnego Bootstrap — udostępnij je lub przypisz do właściwości BodyContent szablonu strony.

Poznawaj dalej

Wszystkie komponenty sgcHTMLPrzejrzyj pełną matrycę funkcji 60+ komponentów.
Pobierz bezpłatną wersję próbną30-dniowa wersja próbna zawiera projekty demonstracyjne 60.HTML.
CennikLicencje Single, Team i Site z pełnym kodem źródłowym.

Gotowy, aby zacząć?

Pobierz bezpłatną wersję próbną i zacznij budować interfejsy webowe w Delphi, C++ Builder i .NET.