type
DWM_BLURBEHIND = record
dwFlags: DWORD;
fEnable: BOOL;
hRgnBlur: HRGN;
fTransitionOnMaximized: BOOL;
end;
function IsWindowsVistaOrLater: Boolean;
var
VerInfo: TOSVersioninfo;
begin
VerInfo.dwOSVersionInfoSize := SizeOf(TOSVersioninfo);
GetVersionEx(VerInfo);
Result := VerInfo.dwMajorVersion >= 6;
end;
function CompositingEnabled: Boolean;
var
DLLHandle: THandle;
DwmIsCompositionEnabledProc: function(pfEnabled: PBoolean): HRESULT;
stdcall;
Enabled :
Boolean;
begin
Result := False;
if IsWindowsVistaOrLater then
begin
DLLHandle := LoadLibrary(dwmapi);
if DLLHandle <> 0 then
begin
@DwmIsCompositionEnabledProc := GetProcAddress(DLLHandle,
DwmIsCompositionEnabledSig);
if (@DwmIsCompositionEnabledProc <> nil) then
begin
DwmIsCompositionEnabledProc(@Enabled);
Result := Enabled;
end;
FreeLibrary(DLLHandle);
end;
end;
end;
function DWM_EnableBlurBehind(const AHandle: HWND; const AMarginsLeft,
AMarginsRight, AMarginsTop, AMarginsBottom: integer): Boolean;
type
_MARGINS = packed record
cxLeftWidth: integer;
cxRightWidth: integer;
cyTopHeight: integer;
cyBottomHeight: integer;
end;
PMargins = ^_MARGINS;
TMargins = _MARGINS;
var
DLLHandle: THandle;
DwmExtendFrameIntoClientAreaProc: function(destWnd: HWND;
const pMarInset: PMargins): HRESULT;
stdcall;
Margins :
TMargins;
begin
Result := False;
if IsWindowsVistaOrLater and CompositingEnabled then
begin
DLLHandle := LoadLibrary(dwmapi);
if DLLHandle <> 0 then
begin
@DwmExtendFrameIntoClientAreaProc := GetProcAddress(DLLHandle,
DwmExtendFrameIntoClientAreaSig);
if (@DwmExtendFrameIntoClientAreaProc <> nil) then
begin
zeromemory(@Margins, SizeOf(Margins));
Margins.cxLeftWidth := AMarginsLeft;
Margins.cxRightWidth := AMarginsRight;
Margins.cyTopHeight := AMarginsTop;
Margins.cyBottomHeight := AMarginsBottom;
if DwmExtendFrameIntoClientAreaProc(AHandle, @Margins) = 0 then
Result := True;
end;
FreeLibrary(DLLHandle);
end;
end;
end;
if CompositingEnabled then
begin
Form.Color := clBlack;
if DWM_EnableBlurBehind(Form.GetWindowHandle, 4, 4, 6, 0) = false then
Form.Color := clWhite;
end;