Notification
TsgcHTMLComponent_Notification — render a bell-icon dropdown notification centre with an unread badge, built from a collection of notification items, in Delphi, C++ Builder and .NET.
TsgcHTMLComponent_Notification — render a bell-icon dropdown notification centre with an unread badge, built from a collection of notification items, in Delphi, C++ Builder and .NET.
A notification-centre component that emits a Bootstrap 5 dropdown. Add items to its Items collection (or call AddNotification), then read the HTML property — the unread UnreadCount drives the badge.
TsgcHTMLComponent_Notification
Bootstrap 5 dropdown markup
Delphi, C++ Builder, .NET
Set Title and MaxVisible, call AddNotification(title, message, color, timestamp) for each entry, then read HTML. The unread count populates the badge automatically.
uses
sgcHTML_Enums, sgcHTML_Component_Notification;
var
oNotif: TsgcHTMLComponent_Notification;
begin
oNotif := TsgcHTMLComponent_Notification.Create(nil);
try
oNotif.Title := 'Notifications';
oNotif.MaxVisible := 5;
oNotif.ShowBadge := True;
oNotif.AddNotification('New order',
'Order #1042 was placed.', hcSuccess, '2 min ago');
oNotif.AddNotification('Payment failed',
'Invoice #88 could not be charged.', hcDanger, '10 min ago');
WebModule.Response := oNotif.HTML; // bell dropdown + badge
finally
oNotif.Free;
end;
end;
// Or add items via the Items collection directly:
with oNotif.Items.Add do
begin
Title := 'Welcome';
Message := 'Your account is ready.';
Color := hcInfo;
end;
// includes: sgcHTML_Enums.hpp, sgcHTML_Component_Notification.hpp
TsgcHTMLComponent_Notification *oNotif = new TsgcHTMLComponent_Notification(NULL);
try
{
oNotif->Title = "Notifications";
oNotif->MaxVisible = 5;
oNotif->ShowBadge = true;
oNotif->AddNotification("New order",
"Order #1042 was placed.", hcSuccess, "2 min ago");
oNotif->AddNotification("Payment failed",
"Invoice #88 could not be charged.", hcDanger, "10 min ago");
String html = oNotif->HTML; // bell dropdown + badge
}
__finally
{
delete oNotif;
}
// Or add items via the Items collection directly:
TsgcHTMLNotificationItem *item = oNotif->Items->Add();
item->Title = "Welcome";
item->Message = "Your account is ready.";
item->Color = hcInfo;
using esegece.sgcWebSockets;
var notif = new TsgcHTMLComponent_Notification();
notif.Title = "Notifications";
notif.MaxVisible = 5;
notif.ShowBadge = true;
notif.AddNotification("New order",
"Order #1042 was placed.", TsgcHTMLColor.hcSuccess, "2 min ago");
notif.AddNotification("Payment failed",
"Invoice #88 could not be charged.", TsgcHTMLColor.hcDanger, "10 min ago");
string html = notif.HTML; // bell dropdown + badge
// Or add items via the Items collection directly:
var item = notif.Items.Add();
item.Title = "Welcome";
item.Message = "Your account is ready.";
item.Color = TsgcHTMLColor.hcInfo;
The members you reach for most often.
Items is a TsgcHTMLNotificationItems collection; each TsgcHTMLNotificationItem has Title, Message, Timestamp, Color, Icon, Href and Read.
AddNotification(title, message, color, timestamp) appends an item and defaults the timestamp to the current time when omitted.
UnreadCount counts items whose Read is False; ShowBadge toggles the red pill and GetBadgeHTML returns just the badge markup.
Title sets the dropdown heading, EmptyText the placeholder when there are no items and BellIcon the trigger glyph.
MaxVisible caps how many items render (default 5), with a "View all" link when more exist; NotificationID assigns the element id.
HTML returns the complete bell-icon dropdown with its scoped CSS — serve it, or assign it to a page template's BodyContent.