Creating a Gradient Form

To beautify the look of the program that you created, you can create a gradient form. The trick is to add code to the OnPaint event of the form like the example below:

procedure TForm1.FormPaint(Sender: TObject);
var Row, Ht: Word;
    IX: Integer;
begin
 iX :=200 ;
 Ht:=(ClientHeight + 512) div 256;
 for Row := 0 to 512 do begin
  with Canvas do begin
  Brush.Color := RGB(Ix,200,row);
  FillRect(Rect(0, Row * Ht, ClientWidth, (Row + 1) * Ht));
  IX :=(IX-1);
  end;
 end;
end;

Untuk mengganti menjadi warna lain, Anda tinggal mengganti pada baris :

Brush.Color := RGB(Ix,200,row);

 

No comments:

Post a Comment