我们看到有些安装程序的背景色自上由下由蓝变黑,我们可以通过下列程序实现
双击窗体的OnPaint事件,然后编写如下程序:
(delphi7下编译通过)
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Mask; type TForm1 = class(TForm) medt1: TMaskEdit; procedure FormPaint(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.FormPaint(Sender: TObject); var i:word; y,dy:Real; begin dy := ClientHeight / 256; y := 0; for i:= 255 downto 0 do begin Canvas.Brush.Color := $00000000 + i * $10000; Canvas.FillRect(Rect(0,Round(y),ClientWidth,Round(y+dy))); y := y + dy; end; end; end.