Windows Fluent Design: Blur the Window Background of Your VFP Forms (Windows 10 / 11) Hi everyone, Push Your VFP App to the next Level: [b]Blur / Acrylic Blur[/b] - the VFP developer can use this free DLL WindowComposition.dll to blur every window background under Windows 10 and 11 !!! Just like e.g. the left side of the Setting Windows or the Taskbar of Windows 10 / 11 !!! The DLL [b]WindowComposition.dll[/b] exports only one (!!!) function: [b]WindowBackgroundBlur[/b]. This internally calls the function SetWindowCompositionAttribute of the Windows DLL User32.dll ((C++ source code attached, see: WindowComposition.cpp). how it works: 1) set the Backcolor of Your Form to colorKey 2) make Your Form a Layered Window 3) set the colorKey of this Layered Window 4) call DLL Function WindowBackgroundBlur (calls Function SetWindowCompositionAttribute): Blur / Acrylic Blur :-) [code] #DEFINE GWL_EXSTYLE -20 #DEFINE WS_EX_LAYERED 0x00080000 #DEFINE LWA_COLORKEY 0x1 #DEFINE ACCENT_DISABLED 0 #DEFINE ACCENT_ENABLE_GRADIENT 1 #DEFINE ACCENT_ENABLE_TRANSPARENTGRADIENT 2 #DEFINE ACCENT_ENABLE_BLURBEHIND 3 && Blur Effect - like Windows Vista / 7 Glass #DEFINE ACCENT_ENABLE_ACRYLICBLURBEHIND 4 && Acrylic Blur Effect - like Windows 10 / 11 #DEFINE ACCENT_ENABLE_HOSTBACKDROP 5 #DEFINE ACCENT_INVALID_STATE 6 #DEFINE DRAW_NO_BORDERS 0x00 #DEFINE DRAW_LEFT_BORDER 0x20 #DEFINE DRAW_TOP_BORDER 0x40 #DEFINE DRAW_RIGHT_BORDER 0x80 #DEFINE DRAW_BOTTOM_BORDER 0x100 #DEFINE DRAW_ALL_BORDERS 0x20 + 0x40 + 0x80 + 0x100 FUNCTION _GetWindowLong( hWnd, indexVal ) LOCAL ret DECLARE INTEGER GetWindowLong IN WIN32API; INTEGER hWnd,; INTEGER nIndex ret = GetWindowLong( hWnd, indexVal ) RETURN ret ENDFUNC FUNCTION _SetWindowLong( hWnd, indexVal, newValue ) LOCAL ret DECLARE INTEGER SetWindowLong IN WIN32API; INTEGER hWnd,; INTEGER nIndex,; INTEGER dwNewLong ret = SetWindowLong( hWnd, indexVal, newValue ) RETURN ret ENDFUNC FUNCTION layeredWindowActivate( hWnd ) && Activate Layered Window LOCAL winStyle winStyle = _GetWindowLong( hWnd, GWL_EXSTYLE ) && get Extended Window Style winStyle = BITOR( winStyle, WS_EX_LAYERED ) && add Layered Window Style _SetWindowLong( hWnd, GWL_EXSTYLE, winStyle ) && set Extended Window Style ENDFUNC FUNCTION _SetLayeredWindowAttributes( hWnd, crKey, alphaVal, flagsVal ) LOCAL ret DECLARE INTEGER SetLayeredWindowAttributes IN WIN32API; INTEGER hWnd,; INTEGER crKey,; INTEGER bAlpha,; INTEGER dwFlags ret = SetLayeredWindowAttributes( hWnd, crKey, alphaVal, flagsVal ) RETURN ret ENDFUNC FUNCTION windowColorKeySet( hWnd, colorKey ) && set colorKey of Layered Window, must be equal to Form Backcolor layeredWindowActivate( hWnd ) _SetLayeredWindowAttributes( hWnd, colorKey, 0, LWA_COLORKEY ) ENDFUNC FUNCTION GradientColorGet( colorVal, alphaVal ) && compose gradientColor = Red + Green + Blue + Alpha (= 0x AA BB GG RR) LOCAL gradientColor gradientColor = colorVal + BITLSHIFT( alphaVal, 24 ) RETURN gradientColor ENDFUNC FUNCTION StartWindowBackgroundBlur( hWnd, accentState, accentFlags, blurColor, alphaVal, animationId ) LOCAL gradientColor LOCAL errorCode gradientColor = GradientColorGet( blurColor, alphaVal ) DECLARE INTEGER WindowBackgroundBlur IN WindowComposition.dll; INTEGER hWnd,; INTEGER accentState,; INTEGER accentFlags,; INTEGER gradientColor,; INTEGER animationId errorCode = WindowBackgroundBlur( hWnd, accentState, accentFlags, gradientColor, animationId ) IF errorCode != 0 messText = "Last Error: " + ALLTRIM( STR( errorCode ) ) MESSAGEBOX( messText, 0 + 48 ) RETURN .F. ENDIF RETURN .T. ENDFUNC * now we start the Blur / Acrylic Blur Effect * ------------------------------------------- * at Design Time set the Form Property Desktop = .T. !!! THISFORM.LockScreen = .T. && don't make any changes to the window immediatly colorKey = RGB( 191, 192, 193 ) && see description below THISFORM.BackColor = colorKey && set Form Backcolor to colorKey windowColorKeySet( hWnd, colorKey ) && set colorKey to Layered Window * accentState = ACCENT_ENABLE_BLURBEHIND && Blur Effect - like Windows Vista / 7 Glass accentState = ACCENT_ENABLE_ACRYLICBLURBEHIND && Acrylic Blur Effect - like Windows 10 / 11 accentFlags = DRAW_NO_BORDERS blurColor = RGB( 0, 128, 190 ) && try different values alphaVal = 128 && 128 = best Blur Effect, see description below animationId = 0 && seems to have no effect ... StartWindowBackgroundBlur( hWnd, accentState, accentFlags, blurColor, alphaVal, animationId ) && Blur / Acrylic Blur *THISFORM.OleControl1.Refresh && ActiveX / OCX on Form: perhaps needs a Refersh to blur ActiveX / OCX background THISFORM.LockScreen = .F. && make all changes to the window at once [/code] hwnd: use the hWnd of Your VFP Form (or _VFP.hWnd or _SCREEN.hWnd ??? or etc.) colorKey: RGB( x, y, z ) three slightly different values and the window background remains clickable colorKey: RGB( x, x, x ) three equal values and the window background becomes clickable through colorKey: Controls on the Form are rendered to this Color in transition to the background !!! (Visual FoxPro doesn't know the Blur Effect Color of the background) blurColor: Color of the Blur Effect alphaVal: 0 (Blur Effect is more transparent) ... 128 (best Blur Effect) ... 255 (Blur Effect is more opaque) animationId: seems to have no effect ... Nice Effect: looks like a weightless floating window :-) THISFORM.BorderStyle = 0 && No Border THISFORM.TitleBar = 0 && TitleBar Off [b]- Screenshot 1[/b]: 3 VFP Forms with blurred background (in front of Windows Desktop): http://www.memotech.de/WindowComposition/WindowBackgroundBlur.jpg [b]- Screenshot 2[/b]: 2 VFP Forms with blurred background (in front of a Google Search): http://www.memotech.de/WindowComposition/WindowsFluentDesign.jpg [b]Download[/b]: www.memotech.de/WindowComposition/WindowComposition.zip Regards, Stefan