可生成一个透明窗体的程序,代码差不多是照搬的,请教各位大侠,问题出在哪里??
这是偶在教程里学习编写的一个程序,可生成一个透明窗体,代码差不多是照搬的,不知道问题出在哪里?请各位高手指点??unit UnitONE;
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;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Doinvisible;
var
Acontrol:TControl;
A,Margin,X,Y,Ctlx,Ctly:Integer;
{ FullRgn:=???;这里原本没有的,该如何处理啊,如果要定义,这是个什么类型的变量啊}
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);
CombinRgn(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;
end;
procedure TForm1.DOVisible;
begin
FullGgn:=CreateRecRgn(0,0,Width,Height);
COmbineRgn(FUllRgn,FullRgn,FUllRgn,RGN_COPY);
SetWindowRgn(Handle,FullRgn,TRUE);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Application.Terminate ;
end;
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 Button1.Caption:='Show' then begin
Dovisible;
Button1.Caption:='Hide';
end
else begin
DoInvesible;
Button1.Caption:='Show';
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
DoInvisible;
end;
end.
[ 本帖最后由 寻H不得 于 2010-10-13 16:08 编辑 ]