D
dinjian
Unregistered / Unconfirmed
GUEST, unregistred user!
先看源代码:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
type
TForm1 = class(TForm)
procedure FormPaint(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
din:integer;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
w:integer;
h:integer;
hdc1:hdc;
implementation
{$R *.DFM}
procedure TForm1.FormPaint(Sender: TObject);
var
i:integer;
j:integer;
k:integer;
n:integer;
red:integer;
green:integer;
blue:integer;
begin
hdc1:=getdc(handle);
randomize();
w:=width;
h:=Height ;
i:=0;
while i<w do
begin
j:=0;
while j<h do
begin
red:=random(255);
green:=random(255);
blue:=random(255);
for k:=i to i+4 do
begin
for n:=j to j+4 do
begin
SetPixel (hdc1,k,n,rgb(red,green,blue));
end;
end;
j:=j+5;
end;
i:=i+5;
end;
din:=din+1;
showmessage(inttostr(din));
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
din:=0;
end;
end.
我以为结果只会对form1画一次,但从结果来看,好象这个窗体不断的被Paint。
请教一下高手,这是什么原因?是不是操作系统不断的发出命令,使窗体重画?谢谢
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
type
TForm1 = class(TForm)
procedure FormPaint(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
din:integer;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
w:integer;
h:integer;
hdc1:hdc;
implementation
{$R *.DFM}
procedure TForm1.FormPaint(Sender: TObject);
var
i:integer;
j:integer;
k:integer;
n:integer;
red:integer;
green:integer;
blue:integer;
begin
hdc1:=getdc(handle);
randomize();
w:=width;
h:=Height ;
i:=0;
while i<w do
begin
j:=0;
while j<h do
begin
red:=random(255);
green:=random(255);
blue:=random(255);
for k:=i to i+4 do
begin
for n:=j to j+4 do
begin
SetPixel (hdc1,k,n,rgb(red,green,blue));
end;
end;
j:=j+5;
end;
i:=i+5;
end;
din:=din+1;
showmessage(inttostr(din));
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
din:=0;
end;
end.
我以为结果只会对form1画一次,但从结果来看,好象这个窗体不断的被Paint。
请教一下高手,这是什么原因?是不是操作系统不断的发出命令,使窗体重画?谢谢