05-17-2024, 08:13 PM
Is there a command or way to set your program to stay on top of other windows (and keep running), even if it doesn't have the focus?
If there is, then I want to make line 31 enable always on top in the programs below, and line 34 disable always on top.
Is this possible? Any info appreciated!
Program #1:
Program #2:
If there is, then I want to make line 31 enable always on top in the programs below, and line 34 disable always on top.
Is this possible? Any info appreciated!
Program #1:
Code: (Select All)
Const cProgName = "Program #1": _Title cProgName
Const FALSE = 0: Const TRUE = Not FALSE
' TEXT MODE COLORS:
Const cBlack = 0: Const cBlue = 1: Const cGreen = 2: Const cLtBlue = 3
Const cRed = 4: Const cPurple = 5: Const cOrange = 6: Const cWhite = 7
Const cGray = 8: Const cPeriwinkle = 9: Const cLtGreen = 10: Const cCyan = 11
Const cLtRed = 12: Const cPink = 13: Const cYellow = 14: Const cLtGray = 15
' COUNT UNTIL USER HITS ESC
Screen 12 ' SCREEN 12 can use 16 color attributes with a black background. 256K possible RGB color hues. Background colors can be used with QB64.
Cls , cBlue
Color cWhite, cBlue
Dim iLoop As Integer
Dim bOnTop As Integer: bOnTop = FALSE
Locate 5, 20 ' y,x where 1,1 = top left
Print cProgName
Locate 10, 20
Print "Press A to stay on top, B for background"
Locate 25, 20 ' y,x where 1,1 = top left
Print "Hold down ESC to exit."
For iLoop = 0 To 10000
Locate 15, 20
Print IIFSTR$(bOnTop, "STAY ON TOP", "BACKGROUND ")
Locate 20, 20 ' y,x where 1,1 = top left
Print _Trim$(Str$(iLoop)) + " "
While _DeviceInput(1): Wend ' clear and update the keyboard buffer
If _KeyDown(Asc("a")) Or _KeyDown(Asc("A")) Then
bOnTop = TRUE
'(ENABLE ALWAYS STAY ON TOP)
ElseIf _KeyDown(Asc("b")) Or _KeyDown(Asc("B")) Then
bOnTop = FALSE
'(DISABLE ALWAYS STAY ON TOP)
End If
If _KeyDown(27) Then Exit For ' leave loop when ESC key pressed
_Limit 4 ' keep loop at 4 frames per second
Next iLoop
End
Function IIF (Condition, IfTrue, IfFalse)
If Condition Then IIF = IfTrue Else IIF = IfFalse
End Function
Function IIFSTR$ (Condition, IfTrue$, IfFalse$)
If Condition Then IIFSTR$ = IfTrue$ Else IIFSTR$ = IfFalse$
End Function
Code: (Select All)
Const cProgName = "Program #2": _Title cProgName
Const FALSE = 0: Const TRUE = Not FALSE
' TEXT MODE COLORS:
Const cBlack = 0: Const cBlue = 1: Const cGreen = 2: Const cLtBlue = 3
Const cRed = 4: Const cPurple = 5: Const cOrange = 6: Const cWhite = 7
Const cGray = 8: Const cPeriwinkle = 9: Const cLtGreen = 10: Const cCyan = 11
Const cLtRed = 12: Const cPink = 13: Const cYellow = 14: Const cLtGray = 15
' COUNT UNTIL USER HITS ESC
Screen 12 ' SCREEN 12 can use 16 color attributes with a black background. 256K possible RGB color hues. Background colors can be used with QB64.
Cls , cRed
Color cWhite, cRed
Dim iLoop As Integer
Dim bOnTop As Integer: bOnTop = FALSE
Locate 5, 20 ' y,x where 1,1 = top left
Print cProgName
Locate 10, 20
Print "Press A to stay on top, B for background"
Locate 25, 20 ' y,x where 1,1 = top left
Print "Hold down ESC to exit."
For iLoop = 10000 To 0 Step -1
Locate 15, 20
Print IIFSTR$(bOnTop, "STAY ON TOP", "BACKGROUND ")
Locate 20, 20 ' y,x where 1,1 = top left
Print _Trim$(Str$(iLoop)) + " "
While _DeviceInput(1): Wend ' clear and update the keyboard buffer
If _KeyDown(Asc("a")) Or _KeyDown(Asc("A")) Then
bOnTop = TRUE
'(ENABLE ALWAYS STAY ON TOP)
ElseIf _KeyDown(Asc("b")) Or _KeyDown(Asc("B")) Then
bOnTop = FALSE
'(DISABLE ALWAYS STAY ON TOP)
End If
If _KeyDown(27) Then Exit For ' leave loop when ESC key pressed
_Limit 4 ' keep loop at 4 frames per second
Next iLoop
End
Function IIF (Condition, IfTrue, IfFalse)
If Condition Then IIF = IfTrue Else IIF = IfFalse
End Function
Function IIFSTR$ (Condition, IfTrue$, IfFalse$)
If Condition Then IIFSTR$ = IfTrue$ Else IIFSTR$ = IfFalse$
End Function