给你代码: const WS_EX_LAYERED = $80000; LWA_ALPHA = $2;在formshow中 var Longi:Longint; begin Longi:=GetWindowLong(Handle, GWL_EXSTYLE); Longi := Longi Or WS_EX_LAYERED; SetWindowLong (handle, GWL_EXSTYLE, Longi); SetLayeredWindowAttributes (handle, 0, 180, LWA_ALPHA); end;
procedure Tmainfrm.FormCreate(Sender: TObject); begin mainfrm.style:=bsclear; end;
var FullRgn, ClientRgn, CtlRgn : THandle;procedure TForm1.DoInvisible; var AControl : TControl; A, Margin, X, Y, CtlX, CtlY : Integer; begin Margin := ( Width - ClientWidth ) div 2; //First, get form region FullRgn := CreateRectRgn(0, 0, Width, Height); //Find client area region X := Margin; Y := Height - ClientHeight - Margin; ClientRgn := CreateRectRgn( X, Y, X + ClientWidth, Y + ClientHeight ); //'Mask' out all but non-client areas CombineRgn( FullRgn, FullRgn, ClientRgn, RGN_DIFF ); //Now, walk through all the controls on the form and 'OR' them // into the existing Full region. 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; end; //When the region is all ready, put it into effect: SetWindowRgn(Handle, FullRgn, TRUE); end;以前做的,不过比较复杂,看看好用不,也多请教。
form1.Brush.Clear;
就可以使form透明了!
实现方法如下:
Form.Brush.Style:=bsClear;
就可以使form透明了!
brush.style:=bsclear;即可,如:
procedure TForm1.FormCreate(Sender: TObject);
begin
brush.Style :=bsclear;
end;
begin
form1.Brush.Style:=bsClear;end;
:這樣的只有2000/XP下有效
你找找吧!FLASHGET就用它!
在form1.create中
procedure Tmainfrm.FormCreate(Sender: TObject);
begin
mainfrm.Brush.Style:=bsClear;
// ^
// |
//你的窗体
end;
const
WS_EX_LAYERED = $80000;
LWA_ALPHA = $2;在formshow中
var
Longi:Longint;
begin
Longi:=GetWindowLong(Handle, GWL_EXSTYLE);
Longi := Longi Or WS_EX_LAYERED;
SetWindowLong (handle, GWL_EXSTYLE, Longi);
SetLayeredWindowAttributes (handle, 0, 180, LWA_ALPHA);
end;
begin
mainfrm.style:=bsclear;
end;
FullRgn, ClientRgn, CtlRgn : THandle;procedure TForm1.DoInvisible;
var
AControl : TControl;
A, Margin, X, Y, CtlX, CtlY : Integer;
begin
Margin := ( Width - ClientWidth ) div 2;
//First, get form region
FullRgn := CreateRectRgn(0, 0, Width, Height);
//Find client area region
X := Margin;
Y := Height - ClientHeight - Margin;
ClientRgn := CreateRectRgn( X, Y, X + ClientWidth, Y + ClientHeight );
//'Mask' out all but non-client areas
CombineRgn( FullRgn, FullRgn, ClientRgn, RGN_DIFF ); //Now, walk through all the controls on the form and 'OR' them
// into the existing Full region.
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;
end;
//When the region is all ready, put it into effect:
SetWindowRgn(Handle, FullRgn, TRUE);
end;以前做的,不过比较复杂,看看好用不,也多请教。