DownNumGlyphs and UpNumGlyphs (C++)

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

class TForm1 : public TForm
{
__published:	// IDE-managed Components
	TImage *Image1;
	TImage *Image2;
	TButton *Button1;
	TSpinEdit *SpinEdit1;
	void __fastcall Button1Click(TObject *Sender);
private:	// User declarations
public:		// User declarations
	__fastcall TForm1(TComponent* Owner);
};

In the .CPP file.

TForm1 *Form1;

void __fastcall TForm1::Button1Click(TObject *Sender)
{
	            	Graphics::TBitmap *BitmapUp;
Graphics::TBitmap *BitmapDown;

BitmapDown =new Graphics::TBitmap();
BitmapUp =new Graphics::TBitmap();
BitmapDown->LoadFromFile("glyphd.bmp");
BitmapUp->LoadFromFile("glyphu.bmp");

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;
}

Uses