State and Widget
TTMSFNCCheckBox works like a standard check box while adding HTML-capable text, widget positioning, and optional bitmap-container artwork.
Read and Set State
Use Checked to set the initial state and to read the user's choice. Handle OnChange when the form should react immediately.
procedure TForm1.ConfigureCheckBox;
begin
TMSFNCCheckBox1.Text := 'Enable notifications';
TMSFNCCheckBox1.Checked := True;
TMSFNCCheckBox1.OnChange := TMSFNCCheckBox1Change;
end;
procedure TForm1.TMSFNCCheckBox1Change(Sender: TObject);
begin
TMSFNCBadge1.Visible := TMSFNCCheckBox1.Checked;
end;
Change Widget Position
Set WidgetPosition to move the check widget to the left or right side of the text.
procedure TForm1.MoveCheckBoxWidget;
begin
TMSFNCCheckBox1.WidgetPosition := hwpRight;
TMSFNCCheckBox1.Text := '<b>Required</b> option';
end;
Use Custom Widget Images
Assign BitmapContainer and set BitmapName when the check widget should use project artwork instead of the default drawing.
procedure TForm1.ConfigureCustomCheckBoxArt;
begin
TMSFNCCheckBox1.BitmapContainer := TMSFNCBitmapContainer1;
TMSFNCCheckBox1.BitmapName := 'check-round';
end;
Combining state, widget position, and custom images
This example positions the check widget on the right, uses a bitmap container for
the tick artwork, and wires OnChange to show an inline notification badge — all
three customizations in one setup:
procedure TForm1.FormCreate(Sender: TObject);
begin
// State
TMSFNCCheckBox1.Text := '<b>Send notifications</b>';
TMSFNCCheckBox1.Checked := True;
TMSFNCCheckBox1.OnChange := CheckBoxChange;
// Widget position: check on the right of the label
TMSFNCCheckBox1.WidgetPosition := hwpRight;
// Custom widget artwork from a bitmap container
TMSFNCCheckBox1.BitmapContainer := TMSFNCBitmapContainer1;
TMSFNCCheckBox1.BitmapName := 'check-circle';
end;
procedure TForm1.CheckBoxChange(Sender: TObject);
begin
NotificationBadge.Visible := TMSFNCCheckBox1.Checked;
end;