DownNumGlyphs and UpNumGlyphs (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This example shows how to dynamically change the Vcl.Samples.Spin.TSpinButton.DownNumGlyphs and the Vcl.Samples.Spin.TSpinButton.DownGlyph of a Vcl.Samples.Spin.TSpinButton. The same principle is applied for Spin.TSpinButton.UpNumGlyphs and Spin.TSpinButton.UpNumGlyph. To do this example, you need two .bmp files that have drawn on them the 4 states of the button listed in Vcl.Samples.Spin.TSpinButton.DownGlyph. glyphd.bmp is used for the Down button and glyphu.bmp--for the Up button.

Code

type
  TForm1 = class(TForm)
    SpinEdit1: TSpinEdit;
    BitBtn2: TBitBtn;
    Image1: TImage;
    Label1: TLabel;
    Image2: TImage;
    procedure BitBtn2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.BitBtn2Click(Sender: TObject);
var
  BitmapUp, BitmapDown: TBitmap;
begin
  BitmapDown := TBitmap.Create;
  BitmapUp := TBitmap.Create;
  BitmapDown.LoadFromFile('glyphd.bmp');
  BitmapUp := TBitmap.Create;
  BitmapUp.LoadFromFile('glyphu.bmp');

 //Displays the two images on the form 
  Form1.Image1.Picture.Bitmap := BitmapUp;
  Form1.Image2.Picture.Bitmap := BitmapDown;

  //Spin button
  Form1.SpinEdit1.Button.DownGlyph := BitmapDown;
  Form1.SpinEdit1.Button.DownNumGlyphs := 4;

  Form1.SpinEdit1.Button.UpGlyph := BitmapUp;
  Form1.SpinEdit1.Button.UpNumGlyphs := 4;

end;

Uses