Set color of text and backgroud

Posted in Graphics

One of the ways to set text color and background color is using SetTextColor and SetBkColor function.

procedure TForm1.Button1Click(Sender: TObject);
begin
  SetTextColor(Form1.Canvas.Handle, clRed);
  SetBkColor(Form1.Canvas.Handle, clGray);
  SetBkMode(Form1.Canvas.Handle, OPAQUE);
  Form1.Canvas.TextOut(10, 10, 'Test Test Test Test Test Test');
end;