Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What bone-head thing did I miss this time?
#9
I've made three different ways to handle that. One of the simplest...

Code: (Select All)
CONST HWND_TOPMOST%& = -1
CONST SWP_NOSIZE%& = &H1
CONST SWP_NOMOVE%& = &H2
CONST SWP_SHOWWINDOW%& = &H40

DECLARE DYNAMIC LIBRARY "user32"
    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 GetForegroundWindow& 'find currently focused process handle
END DECLARE

' Needed for acquiring the hWnd of the window
DIM hWnd AS LONG ' Get hWnd value

DO ' Title window and get handle.
    _LIMIT 30
    _TITLE "Persistency Window Demo"
    hWnd = _WINDOWHANDLE
    i = i + 1: IF i > 100000 THEN PRINT "Cannt get window handle.": END
LOOP UNTIL hWnd

wdth = 300: hght = 400

' Set screen
s& = _NEWIMAGE(wdth, hght, 32)
SCREEN s&
_DEST 0

_SCREENMOVE 800, 50
' Main loop
Level = 175
_DELAY .1

DO
    _LIMIT 30
    FGwin& = GetForegroundWindow&

    IF hWnd <> FGwin& THEN ' QB64 no longer in focus.
        WHILE _MOUSEINPUT: WEND
        y& = SetWindowPos&(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE + SWP_SHOWWINDOW)
        PRINT y&, hWnd, HWND_TOPMOST%&, SWP_NOSIZE%& + SWP_NOMOVE%& + SWP_SHOWWINDOW%&
        DO: _LIMIT 30: LOOP UNTIL hWnd = GetForegroundWindow&
    END IF
    IF INKEY$ = CHR$(27) THEN SYSTEM
LOOP

Pete

API Queen... Dammit Steve!
Reply


Messages In This Thread
RE: What bone-head thing did I miss this time? - by Pete - 10-29-2022, 02:06 AM



Users browsing this thread: 9 Guest(s)