FUNCTION GetForegroundWindow&
'find currently focused process handle
' Needed for acquiring the hWnd of the window
_TITLE "Translucent window test"
' Set screen
' Main loop
Level = 175
SetWindowOpacity Myhwnd, Level
LOCATE 1, 1:
PRINT "Press F1/F2 to change opacity:"; Level;
LOCATE 2, 1:
PRINT "Drag to change window size:"; wdth; hght
y = 3: x = 1
oldimage& = s&
LOCATE 1, 1:
PRINT "Press F1/F2 to change opacity:"; Level;
LOCATE 2, 1:
PRINT "Drag to change window size:"; wdth; hght
oldimage& = s&
FGwin& = GetForegroundWindow&
IF Myhwnd
<> FGwin&
THEN ' QB64 no longer in focus. SetWindowOpacity Myhwnd, 0
x& = ShowWindow&(Myhwnd, 2)
x& = ShowWindow&(Myhwnd, 10)
SetWindowOpacity Myhwnd, Level
oldimage& = 0
IF b$
= CHR$(0) + CHR$(59) AND Level
< 255 THEN Level
= Level
+ 1: SetWindowOpacity Myhwnd
, Level
IF b$
= CHR$(0) + CHR$(60) AND Level
> 0 THEN Level
= Level
- 1: SetWindowOpacity Myhwnd
, Level
mystring$ = mystring$ + b$
'====================================================================\
CONST WS_EX_LAYERED
= &H80000 Msg = GetWindowLong(hwnd, G)
Msg
= Msg
OR WS_EX_LAYERED
action = SetWindowLong(hwnd, G, Msg)
action = SetLayeredWindowAttributes(hwnd, 0, Level, LWA_ALPHA)