StefanFoerner
Programmer
Hi everyone,
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: this makes the Background transparent
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 Transparency Effect of the background)
Screenshot: 3 VFP Forms with Transparency, BorderStyle = 0 (No Border), TitleBar = 0 (Titlebar Off): www.memotech.de/WindowTransparency/WindowTransparency.jpg
=> Windows Fluent Design: next week we want to blur the window background of VFP Forms as an extension based on the code above
Regards, Stefan
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: this makes the Background transparent
Code:
#DEFINE GWL_EXSTYLE -20
#DEFINE WS_EX_LAYERED 0x00080000
#DEFINE LWA_COLORKEY 0x1
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
* now we start the Transparency 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 ) && this makes the Background transparent
THISFORM.LockScreen = .F. && make all changes to the window at once
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 Transparency Effect of the background)
Screenshot: 3 VFP Forms with Transparency, BorderStyle = 0 (No Border), TitleBar = 0 (Titlebar Off): www.memotech.de/WindowTransparency/WindowTransparency.jpg
=> Windows Fluent Design: next week we want to blur the window background of VFP Forms as an extension based on the code above
Regards, Stefan