05-04-2022, 02:48 AM
Another example:
Code: (Select All)
CONST HWND_TOPMOST%& = -1
CONST SWP_NOSIZE%& = &H1
CONST SWP_NOMOVE%& = &H2
CONST SWP_SHOWWINDOW%& = &H40
DECLARE DYNAMIC LIBRARY "User32"
FUNCTION GetWindowLongA& (BYVAL hwnd AS LONG, BYVAL nIndex AS LONG)
FUNCTION SetWindowPos& (BYVAL hWnd AS LONG, BYVAL hWndInsertAfter AS _OFFSET, BYVAL X AS INTEGER, BYVAL Y AS INTEGER, BYVAL cx AS INTEGER, BYVAL cy AS INTEGER, BYVAL uFlags AS _OFFSET)
FUNCTION SetWindowLongA& (BYVAL hwnd AS LONG, BYVAL nIndex AS LONG, BYVAL dwNewLong AS LONG)
FUNCTION GetForegroundWindow&
FUNCTION SetLayeredWindowAttributes& (BYVAL hwnd AS LONG, BYVAL crKey AS LONG, BYVAL bAlpha AS _UNSIGNED _BYTE, BYVAL dwFlags AS LONG)
END DECLARE
SCREEN _NEWIMAGE(2560, 1440, 32)
$COLOR:32
COLOR CrayolaGold, DarkCyan
_SCREENMOVE 0, 0 ' Move screen to top left corner.
CLS
_DELAY .1
GWL_STYLE = -16
ws_border = &H800000
WS_VISIBLE = &H10000000
_TITLE "Borderless Window"
DIM hwnd AS LONG
hwnd = _WINDOWHANDLE
_DELAY .1
Level = 175
winstyle2& = GetWindowLongA&(hwnd, GWL_STYLE)
winstyle& = -12582913
a& = SetWindowLongA&(hwnd, GWL_STYLE, winstyle& AND WS_VISIBLE) ' AND NOT WS_VSCROLL) ' AND NOT ws_border)
a& = SetWindowPos&(hwnd, 0, 0, 0, 0, 0, 39)
msg$ = "Welcome to Translucent Windows Without Borders!"
i = 16
COLOR &HFFFFFFFF, &H0 ' white foreground, transparent background
DO
_LIMIT 60
FGwin& = GetForegroundWindow&
IF hwnd <> FGwin& THEN ' QB64 no longer in focus.
WHILE _MOUSEINPUT: WEND
a& = SetWindowPos&(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE + SWP_SHOWWINDOW)
DO: _LIMIT 30: LOOP UNTIL hwnd = GetForegroundWindow&
END IF
IF INKEY$ = CHR$(27) THEN EXIT DO
LOOP
SYSTEM
Shoot first and shoot people who ask questions, later.