Y
yaoxing
Unregistered / Unconfirmed
GUEST, unregistred user!
这是原程序:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Panel1: TPanel;
Button1: TButton;
Button2: TButton;
procedure FormResize(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
procedure DoInvisible;
procedure Dovisible;
public
{ Public declarations }
end;
procedure TForm1.DoInvisible;
var
Form1: TForm1;
Acontrol:Tcontrol;
controlcount,clientheight,ClientWidth,width,height,clientrgn,ctlrgn,FullRgn,a,margin,x,y ,ctlx,ctly:integer;
begin
margin:=(width-ClientWidth) div 2;
FullRgn:=CreateRectRgn(0,0,width,height);
x:=margin;
y:=height-clientheight-margin;
clientrgn:=createrectrgn(x,y,x+clientwidth,y+clientheight);
combinergn(fullrgn,fullrgn,clientrgn,rgn_diff);
for a:=0 to controlcount-1 do begin
acontrol:=controls[a];
if (acontrol is twincontrol) or (acontrol is tgraphiccontrol)
then with acontrol do begin
if visible then begin
ctlx:=x+left;
ctly:=y+top;
ctlrgn:=createrectrgn(ctlx,ctly,ctlx+width,ctly+height);
combinergn(fullrgn,fullrgn,ctlrgn,rgn_or);
end;
procedure Tform1.Dovisible;
begin
fullrgn:=createrectrgn(0,0,width,height);
combinergn(fullrgn,fullrgn,fullrgn,rgn_copy);
setwindowrgn(handle,fullrgn,true);
end;
implementation
{$R *.dfm}
procedure TForm1.FormResize(Sender: TObject);
begin
if button1.caption='show' then
doinvisible
else
dovisible;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
deleteobject(clientrgn);
deleteobject(fullrgn);
deleteobject(ctlrgn);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if Button.caption='show' then begin
Dovisible;
Button1.caption:='hide';
end
else begin
Doinvisible;
button1.caption:='show';
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
application.Terminate;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
DoInvisible;
end;
end.
报错信息:
[Error] Unit1.pas(28): Identifier redeclared: 'TForm1.DoInvisible'
[Error] Unit1.pas(32): Statements not allowed in interface part
[Error] Unit1.pas(40): '.' expected but '[' found
[Error] Unit1.pas(49): Statement expected but 'PROCEDURE' found
[Error] Unit1.pas(50): Identifier redeclared: 'TForm1.Dovisible'
[Error] Unit1.pas(53): Undeclared identifier: 'handle'
[Error] Unit1.pas(77): Undeclared identifier: 'Button'
[Error] Unit1.pas(85): Statement expected but 'PROCEDURE' found
[Error] Unit1.pas(21): Unsatisfied forward or external declaration: 'TForm1.DoInvisible'
[Error] Unit1.pas(22): Unsatisfied forward or external declaration: 'TForm1.Dovisible'
[Fatal Error] Project1.dpr(5): Could not compile used unit '../../examples/Unit1.pas'
请指教!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Panel1: TPanel;
Button1: TButton;
Button2: TButton;
procedure FormResize(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
procedure DoInvisible;
procedure Dovisible;
public
{ Public declarations }
end;
procedure TForm1.DoInvisible;
var
Form1: TForm1;
Acontrol:Tcontrol;
controlcount,clientheight,ClientWidth,width,height,clientrgn,ctlrgn,FullRgn,a,margin,x,y ,ctlx,ctly:integer;
begin
margin:=(width-ClientWidth) div 2;
FullRgn:=CreateRectRgn(0,0,width,height);
x:=margin;
y:=height-clientheight-margin;
clientrgn:=createrectrgn(x,y,x+clientwidth,y+clientheight);
combinergn(fullrgn,fullrgn,clientrgn,rgn_diff);
for a:=0 to controlcount-1 do begin
acontrol:=controls[a];
if (acontrol is twincontrol) or (acontrol is tgraphiccontrol)
then with acontrol do begin
if visible then begin
ctlx:=x+left;
ctly:=y+top;
ctlrgn:=createrectrgn(ctlx,ctly,ctlx+width,ctly+height);
combinergn(fullrgn,fullrgn,ctlrgn,rgn_or);
end;
procedure Tform1.Dovisible;
begin
fullrgn:=createrectrgn(0,0,width,height);
combinergn(fullrgn,fullrgn,fullrgn,rgn_copy);
setwindowrgn(handle,fullrgn,true);
end;
implementation
{$R *.dfm}
procedure TForm1.FormResize(Sender: TObject);
begin
if button1.caption='show' then
doinvisible
else
dovisible;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
deleteobject(clientrgn);
deleteobject(fullrgn);
deleteobject(ctlrgn);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if Button.caption='show' then begin
Dovisible;
Button1.caption:='hide';
end
else begin
Doinvisible;
button1.caption:='show';
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
application.Terminate;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
DoInvisible;
end;
end.
报错信息:
[Error] Unit1.pas(28): Identifier redeclared: 'TForm1.DoInvisible'
[Error] Unit1.pas(32): Statements not allowed in interface part
[Error] Unit1.pas(40): '.' expected but '[' found
[Error] Unit1.pas(49): Statement expected but 'PROCEDURE' found
[Error] Unit1.pas(50): Identifier redeclared: 'TForm1.Dovisible'
[Error] Unit1.pas(53): Undeclared identifier: 'handle'
[Error] Unit1.pas(77): Undeclared identifier: 'Button'
[Error] Unit1.pas(85): Statement expected but 'PROCEDURE' found
[Error] Unit1.pas(21): Unsatisfied forward or external declaration: 'TForm1.DoInvisible'
[Error] Unit1.pas(22): Unsatisfied forward or external declaration: 'TForm1.Dovisible'
[Fatal Error] Project1.dpr(5): Could not compile used unit '../../examples/Unit1.pas'
请指教!