unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
const
WS_EX_LAYERED = $80000;
LWA_COLORKEY = 1;
LWA_ALPHA = 2;
type
TForm1 =
class(TForm)
procedure SetTransparentForm(AHandle : THandle; AValue : byte = 0);
procedure FormCreate(Sender: TObject);
procedure FormConstrainedResize(Sender: TObject;
var MinWidth,
MinHeight, MaxWidth, MaxHeight: Integer);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.SetTransparentForm(AHandle : THandle; AValue : byte = 0);
var
Info: TOSVersionInfo;
SetLayeredWindowAttributes: TSetLayeredWindowAttributes;
begin
//Check Windows version
Info.dwOSVersionInfoSize := SizeOf(Info);
GetVersionEx(Info);
if (Info.dwPlatformId = VER_PLATFORM_WIN32_NT)
and
(Info.dwMajorVersion >= 5)
then
begin
SetLayeredWindowAttributes := GetProcAddress(GetModulehandle(user32), '
SetLayeredWindowAttributes');
if Assigned(SetLayeredWindowAttributes)
then
begin
SetWindowLong(AHandle, GWL_EXSTYLE, GetWindowLong(AHandle, GWL_EXSTYLE)
or WS_EX_LAYERED);
//Make form transparent
SetLayeredWindowAttributes(AHandle, 0, AValue, LWA_ALPHA);
end;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
SetTransparentForm(
handle, 125);
end;
procedure TForm1.FormConstrainedResize(Sender: TObject;
var MinWidth,
MinHeight, MaxWidth, MaxHeight: Integer);
begin
SetTransparentForm(
handle, 125);
end;
end.