Header, footer, and action buttons
TTMSFNCPanel can display a header bar above and a footer bar below its content area. Both bars support HTML text, four optional action buttons, and clickable anchor links. The header is visible by default; the footer is hidden by default.
Enabling the header and footer
TMSFNCPanel1.Header.Visible := True;
TMSFNCPanel1.Header.Text := '<b>My Panel</b>';
TMSFNCPanel1.Header.Size := 32; // height in pixels
TMSFNCPanel1.Footer.Visible := True;
TMSFNCPanel1.Footer.Text := 'Status: ready';
Action buttons
Each element (Header or Footer) exposes a Buttons set with four values:
| Value | Button shown | Default action |
|---|---|---|
pbClose |
× close | Hides or frees the panel (CloseAction) |
pbExpander |
▼/▲ expand | Collapses or expands the height (ExpandAction) |
pbCompact |
◀/▶ compact | Collapses or expands the width (CompactAction) |
pbDropDown |
▾ drop-down | Opens a popup control (DropDownAction) |
Enable buttons by assigning the set:
TMSFNCPanel1.Header.Visible := True;
TMSFNCPanel1.Header.Text := 'Results';
TMSFNCPanel1.Header.Size := 30;
// Show close and expand buttons in the header
TMSFNCPanel1.Header.Buttons := [pbClose, pbExpander];
TMSFNCPanel1.CloseAction := pcaHide;
TMSFNCPanel1.ExpandAction := peaExpand;
// Footer with a compact (width-collapse) button
TMSFNCPanel1.Footer.Visible := True;
TMSFNCPanel1.Footer.Text := 'Ready';
TMSFNCPanel1.Footer.Buttons := [pbCompact];
TMSFNCPanel1.CompactAction := pcCompact;
Close behaviour
CloseAction controls what happens when the close button is clicked:
| Value | Effect |
|---|---|
pcaNone |
Nothing — handle OnHeaderCloseButtonClick manually |
pcaHide |
Sets Visible := False (default) |
pcaFree |
Frees the panel |
Expand and compact behaviour
ExpandAction = peaExpand(default): the expand button toggles the panel height between its full height and the header-only height.CompactAction = pcCompact(default): the compact button toggles the panel width between its full width and the header-button-only width.
Call the methods directly to control state in code:
TMSFNCPanel1.Collapse; // collapse height
TMSFNCPanel1.Expand; // restore height
TMSFNCPanel1.Collapse(True); // collapse width (compact)
TMSFNCPanel1.Expand(True); // restore width (compact)
Drop-down popup
Assign any TControl to Header.DropDownControl. When the drop-down button is clicked the control is shown in a popup below the header. Set DropDownWidth and DropDownHeight on the element to size the popup:
TMSFNCPanel1.Header.DropDownControl := MyListBox;
TMSFNCPanel1.Header.DropDownWidth := 200;
TMSFNCPanel1.Header.DropDownHeight := 150;
TMSFNCPanel1.DropDownAction := pddaPopup;
Handling button click events
Each button has a dedicated event. Handle OnHeaderCloseButtonClick if you need custom close logic:
procedure TForm1.TMSFNCPanel1HeaderCloseButtonClick(Sender: TObject);
begin
// Custom close: ask before hiding
if MessageDlg('Close this panel?', TMsgDlgType.mtConfirmation,
[mbYes, mbNo], 0) = mrYes then
TMSFNCPanel1.Visible := False;
end;
procedure TForm1.TMSFNCPanel1HeaderAnchorClick(Sender: TObject; AAnchor: String);
begin
// Header.Text can contain <a href="..."> links
if AAnchor = 'help' then
ShowHelp;
end;
Customising button appearance
ButtonsAppearance.ButtonAppearance controls the fill, stroke, and rounding shared by all buttons. Assign custom SVG bitmaps through ButtonsAppearance.CloseBitmap, ExpandBitmap, CompactBitmap, and DropDownBitmap:
TMSFNCPanel1.ButtonsAppearance.ButtonAppearance.Rounding := 4;
TMSFNCPanel1.ButtonsAppearance.ButtonAppearance.FlatStyle := True;
Combining expand and drop-down in a collapsible filter panel
The example below builds a panel that collapses its content area when the expand button is clicked and shows a filter control in a popup when the drop-down button is clicked:
// Build a collapsible filter panel with a drop-down picker
procedure TForm1.FormCreate(Sender: TObject);
begin
with TMSFNCPanel1 do
begin
Header.Visible := True;
Header.Text := 'Filter';
Header.Size := 32;
Header.Buttons := [pbExpander, pbDropDown];
ExpandAction := peaExpand;
DropDownAction := pddaPopup;
// Assign a pre-created filter control as the drop-down
Header.DropDownControl := FilterComboBox;
Header.DropDownWidth := 220;
Header.DropDownHeight := 180;
Footer.Visible := False;
end;
end;
procedure TForm1.TMSFNCPanel1HeaderExpandButtonClick(Sender: TObject);
begin
// Update a status label to reflect collapse state
if TMSFNCPanel1.ExpandState = pesCollapsed then
StatusLabel.Text := 'Panel collapsed'
else
StatusLabel.Text := 'Panel expanded';
end;