procedure TForm1.Button1Click(Sender: TObject);
var
Bmp: TBitmap;
BlendFunc: TBlendFunction;
PosPt, ZeroPt: TPoint;
Size: TSize;
begin
// Create bitmap for our layered window
Bmp := TBitmap.Create;
Try
Bmp.Width := Width;
Bmp.Height := Height;
Bmp.Canvas.Brush.Color := clBlue;
Bmp.Canvas.FillRect(Rect(0, 0, Bmp.Width, Bmp.Height));
{>>>>} AlphaBlend := False;
// Enable the layered style
SetWindowLong(
Handle, GWL_EXSTYLE, GetWindowLong(
Handle, GWL_EXSTYLE)
or WS_EX_LAYERED);
// Assign the bitmap to the layered window
BlendFunc.BlendOp := AC_SRC_OVER;
BlendFunc.BlendFlags := 0;
BlendFunc.SourceConstantAlpha := 128;
BlendFunc.AlphaFormat := 0;
PosPt := BoundsRect.TopLeft;
Size.cx := Width;
Size.cy := Height;
ZeroPt := Point(0, 0);
Win32Check(UpdateLayeredWindow(
Handle, GetDC(0), @PosPt, @Size, Bmp.Canvas.Handle,
@ZeroPt, clnone, @BlendFunc, ULW_ALPHA));
finally
Bmp.Free;
end;
end;