1 2 //--------------------------------------------------------------------------- 3 4 #include <vcl.h> 5 #pragma hdrstop 6 7 #include "Unit1.h" 8 //--------------------------------------------------------------------------- 9 #pragma package(smart_init) 10 #pragma resource "*.dfm" 11 TForm1 *Form1; 12 //--------------------------------------------------------------------------- 13 __fastcall TForm1::TForm1(TComponent* Owner) 14 : TForm(Owner) 15 { 16 } 17 //--------------------------------------------------------------------------- 18 19 void __fastcall TForm1::Button1Click(TObject *Sender) 20 { 21 //gets the pixels size of text 22 Caption ="Pixel size of text is "+ IntToStr(Canvas->TextWidth("DevSuperpage.com")); 23 24 } 25 //--------------------------------------------------------------------------- 26 27 void __fastcall TForm1::FormCreate(TObject *Sender) 28 { 29 //gets all the fonts installed on your PC and assign them to a comboox 30 ComboBox1->Items->AddStrings( Screen->Fonts); 31 } 32 //--------------------------------------------------------------------------- 33 void __fastcall TForm1::ComboBox1Change(TObject *Sender) 34 { 35 //change the font of the form to get the pixel size 36 Font->Name =ComboBox1->Text; 37 } 38 //--------------------------------------------------------------------------- 39