Skip to main content
Table of Contents

TTMSFNCBitmapSelector Class

Selector control that displays bitmap choices in a configurable item grid.

API unit family: TMSFNCBitmapSelector Inherits from: TTMSFNCCustomBitmapSelector

Syntax

GeneratedPascalC++
TTMSFNCBitmapSelector = class(TTMSFNCCustomBitmapSelector)
class PASCALIMPLEMENTATION TTMSFNCBitmapSelector : public TTMSFNCCustomBitmapSelector

Properties

Name Description
BitmapContainer Gets or sets the bitmap container used to resolve item bitmap names. (inherited from TTMSFNCCustomBitmapSelector)
Items Gets or sets the bitmap item collection displayed by the selector. (inherited from TTMSFNCCustomBitmapSelector)
SelectedBitmap Returns the bitmap associated with the selected item. (inherited from TTMSFNCCustomBitmapSelector)

Methods

Name Description
FindBitmapByItem Finds the bitmap displayed by the item with the specified index. (inherited from TTMSFNCCustomBitmapSelector)
FindItemByBitmap Finds the item index that displays the specified bitmap instance. (inherited from TTMSFNCCustomBitmapSelector)
LoadFromBitmapContainer Populates the item collection from the assigned bitmap container. (inherited from TTMSFNCCustomBitmapSelector)

Events

Name Description
OnBitmapDeselected Occurs after a bitmap item is deselected. (inherited from TTMSFNCCustomBitmapSelector)
OnBitmapSelected Occurs after a bitmap item is selected. (inherited from TTMSFNCCustomBitmapSelector)

Usage examples

Standalone bitmap selector with custom drawing

Populates a 3-column selector and applies custom drawing per item state.

Standalone bitmap selector with custom drawingPascal
procedure TForm1.ConfigureBitmapSelector;
var
  I: Integer;
begin
  TMSFNCBitmapSelector1.BeginUpdate;
  TMSFNCBitmapSelector1.Items.Clear;
  TMSFNCBitmapSelector1.Columns := 3;
  TMSFNCBitmapSelector1.Rows := 1;
  for I := 0 to 2 do
    TMSFNCBitmapSelector1.Items.Add;
  TMSFNCBitmapSelector1.EndUpdate;
end;

procedure TForm1.TMSFNCBitmapSelector1BitmapSelect(Sender: TObject;
  AItemIndex: Integer; ABitmap: TTMSFNCBitmap);
begin
  Caption := 'Selected index: ' + AItemIndex.ToString;
end;

procedure TForm1.TMSFNCBitmapSelector1ItemAfterDrawContent(Sender: TObject;
  AGraphics: TTMSFNCGraphics; ARect: TRectF; AItemIndex: Integer);
var
  pt: TTMSFNCGraphicsPath;
begin
  case TMSFNCBitmapSelector1.Items[AItemIndex].State of
    isHover: InflateRect(ARect, -4, -4);
    isDown, isSelected:
    begin
      InflateRectEx(ARect, -4, -4);
      AGraphics.Stroke.Width := 2;
      AGraphics.Stroke.Color := gcBlack;
    end;
    isNormal: InflateRectEx(ARect, -8, -8);
  end;
  ARect := RectF(Int(ARect.Left) + 0.5, Int(ARect.Top) + 0.5,
    Int(ARect.Right) + 0.5, Int(ARect.Bottom) + 0.5);
  case AItemIndex of
    0: begin AGraphics.Fill.Color := gcBlue;  AGraphics.DrawEllipse(ARect); end;
    1: begin AGraphics.Fill.Color := gcGreen; AGraphics.DrawRectangle(ARect); end;
    2:
    begin
      pt := TTMSFNCGraphicsPath.Create;
      pt.MoveTo(PointF(ARect.Left + ARect.Width / 2, ARect.Top));
      pt.LineTo(PointF(ARect.Right, ARect.Bottom));
      pt.LineTo(PointF(ARect.Left,  ARect.Bottom));
      pt.ClosePath;
      AGraphics.Fill.Color := gcRed;
      AGraphics.DrawPath(pt);
      pt.Free;
    end;
  end;
end;

Read the related guide

Used by