Win2000下的半透明窗体:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons;
type
TForm1 = class(TForm)
Label1: TLabel;
SpeedButton1: TSpeedButton;
procedure FormCreate(Sender: TObject);
procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure SpeedButton1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
//---------------------------------------------------------
function SetLayeredWindowAttributes(Handle: HWND;
COLORKEY: COLORREF; Alpha: BYTE; Flags: DWORD): Boolean; stdcall; external 'USER32.DLL';
Const
WS_EX_LAYERED = $80000;
LWA_ALPHA = 2;
//---------------------------------------------------------
sc_DragMove:longint=$F012;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
SetWindowLong(Handle,GWL_EXSTYLE,GetWindowLong(Handle,GWL_EXSTYLE) or WS_EX_LAYERED);
SetLayeredWindowAttributes(Form1.Handle, RGB(255,255,255), 180, LWA_ALPHA);
color:= RGB(55,55,55);
end;
procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
ReleaseCapture;
SendMessage(handle,wm_SysCommand,
sc_DragMove,0);
end;
procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
Close;
end;
end.