代码如下:
//--------------------------unit1------------------------------------
unit Unit1;interface uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls; type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
procedure WMPaint(var Msg:TWMPaint);message WM_PAINT;
{ Private declarations }
public
{ Public declarations }
end; var
Form1: TForm1; implementation uses Unit2;
var
mesfrm:tform2;
{$R *.dfm} procedure TForm1.Button1Click(Sender: TObject);
begin
mesfrm:=TForm2.Create(application);
mesfrm.Show;
end; procedure TForm1.Button2Click(Sender: TObject);
begin
mesfrm.close();
end; procedure TForm1.WMPaint(var Msg:TWMPaint);
begin
inherited;
ShowMessage('test');
end;
end.//--------------------------unit2--------------------------------
unit Unit2;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, jpeg, StdCtrls;type
TForm2 = class(TForm)
Panel1: TPanel;
private
{ Private declarations }
public
procedure Show;
procedure close();
{ Public declarations }
end;
var
Form2: TForm2;
implementation
//--------------窗体显示函数----------------------
procedure TForm2.close();
begin
if AnimateWindow(Handle,500,AW_VER_POSITIVE+AW_HIDE)=false then
begin
showmessage('窗体退出出错');
free;
end;
inherited close;
end;
//------------窗体关闭函数----------------------
procedure tform2.Show;
begin
//top:=0;
//left:=0;
if AnimateWindow(Handle,500,AW_VER_NEGATIVE)=false then
begin
showmessage('窗体显示出错');
free;
end;
inherited show;
end;
{$R *.dfm}
end.出现的问题:
为何当我把Unit1的窗体最大化后,再点击button2让弹出的动画窗体消逝的时候,TForm1在TForm2动画消逝的过程中不能重绘,而非得等到整个TForm2完全消失后才重绘呢?请高手指点!!
//--------------------------unit1------------------------------------
unit Unit1;interface uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls; type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
procedure WMPaint(var Msg:TWMPaint);message WM_PAINT;
{ Private declarations }
public
{ Public declarations }
end; var
Form1: TForm1; implementation uses Unit2;
var
mesfrm:tform2;
{$R *.dfm} procedure TForm1.Button1Click(Sender: TObject);
begin
mesfrm:=TForm2.Create(application);
mesfrm.Show;
end; procedure TForm1.Button2Click(Sender: TObject);
begin
mesfrm.close();
end; procedure TForm1.WMPaint(var Msg:TWMPaint);
begin
inherited;
ShowMessage('test');
end;
end.//--------------------------unit2--------------------------------
unit Unit2;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, jpeg, StdCtrls;type
TForm2 = class(TForm)
Panel1: TPanel;
private
{ Private declarations }
public
procedure Show;
procedure close();
{ Public declarations }
end;
var
Form2: TForm2;
implementation
//--------------窗体显示函数----------------------
procedure TForm2.close();
begin
if AnimateWindow(Handle,500,AW_VER_POSITIVE+AW_HIDE)=false then
begin
showmessage('窗体退出出错');
free;
end;
inherited close;
end;
//------------窗体关闭函数----------------------
procedure tform2.Show;
begin
//top:=0;
//left:=0;
if AnimateWindow(Handle,500,AW_VER_NEGATIVE)=false then
begin
showmessage('窗体显示出错');
free;
end;
inherited show;
end;
{$R *.dfm}
end.出现的问题:
为何当我把Unit1的窗体最大化后,再点击button2让弹出的动画窗体消逝的时候,TForm1在TForm2动画消逝的过程中不能重绘,而非得等到整个TForm2完全消失后才重绘呢?请高手指点!!
除非你用独立线程处理,比较复杂和麻烦的