[Back To Directory]

Changing RichEdit Font Size:

1. Open Borland C++ Builder.
2. Place a RichEdit box of the form and make it at leste width 300 by height 300.
3. Place a Button on the form.
4. Place an Edit box on the form and set the text value to 12. 5. Double click Button1.
6. Type the following red code in the Button1Click function:

//This is what the Button1Click function should look like:

void __fastcall TForm1::Button1Click(TObject *Sender)
{
   //font size by points
   RichEdit1->SelAttributes->Size = atoi(Edit1->Text.c_str());
   RichEdit1->SetFocus();
}
//---------------------------------------------------------------------------


7. Plache another Button on the form.
8. Place another Edit box on the form and set the text value to 12. 9. Double click Button2.
10. Enter the following red code into the Button2Click function:

//heres what the Button2Click function should look like:

void __fastcall TForm1::Button2Click(TObject *Sender)
{
   //font size by pixels
   RichEdit1->SelAttributes->Height = atoi(Edit2->Text.c_str());
   RichEdit1->SetFocus();
}
//---------------------------------------------------------------------------


11. Run the program. Type a value in Edit1 and click Button1, the font will be sized by points.
Type a value in Edit2 and click Button2, the font will be sized by pixels.





[Back To Directory]