Ja, für Formulare, aber nicht für einzelne Komponenten, in diesem Fall den Stringgrid.
Nur mal so runtergetippt,
Beispielvideo hier:
Delphi-Quellcode:
procedure TForm1.CheckBox1Click(Sender: TObject);
var
isTransparent: Boolean;
begin
isTransparent := (Sender as TCheckBox).Checked;
setIsStringGridTransparent(isTransparent);
end;
procedure TForm1.setIsStringGridTransparent(const isTransparent: Boolean);
var
exStyle: DWORD;
begin
exStyle := GetWindowLongPtr(StringGrid1.Handle, GWL_EXSTYLE);
Win32Check(exStyle <> 0);
if(isTransparent) then
begin
exStyle := (exStyle or WS_EX_LAYERED);
Win32Check(
SetWindowLongPtr(StringGrid1.Handle, GWL_EXSTYLE, exStyle)
<>
0
);
Win32Check( SetLayeredWindowAttributes(
StringGrid1.Handle,
0,
127, // 50 % von 255
LWA_ALPHA
) );
end
else
begin
exStyle := (exStyle xor WS_EX_LAYERED);
SetWindowLong(StringGrid1.Handle, GWL_EXSTYLE, exStyle);
end;
end;