How do I know, if a screensaver is running?
Posted: Sun Jun 29, 2003 2:52 pm
I have to know, if a screensaver or a DirectX-game in Fullscreenmode is running. to prevent my program from making screenoutputs. How do I do this?
http://www.purebasic.com
https://www.purebasic.fr/english/
If you have your own fullscreen game then you should use IsScreenActive() to know if your own screen is the active one.high key wrote:I have to know, if a screensaver or a DirectX-game in Fullscreenmode is running. to prevent my program from making screenoutputs. How do I do this?
Code: Select all
Procedure.l cb(window.l, Message.l, wParam.l, lParam.l)
If Message = #WM_DISPLAYCHANGE
lp.l = lParam
dep.l = wParam
hres.l = lp & 65535
vres.l = (lp / 65536) & 65535
SetGadgetText(1, "Display changed to "+Str(hres)+" x "+Str(vres)+" x "+Str(dep))
EndIf
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
If OpenWindow(0, 200, 200, 400, 300, 0, "Checker")
If CreateGadgetList(WindowID())
StringGadget(1, 10, 10, 380, 30, "")
EndIf
SetWindowCallback(@cb())
While quit=0
ev.l = WindowEvent()
While ev
Select ev
Case #WM_DISPLAYCHANGE
Case #PB_Event_CloseWindow
quit = 1
EndSelect
ev = WindowEvent()
Wend
Delay(100)
Wend
SetWindowCallback(0)
CloseWindow(0)
EndIf
End
OK. I couldn't find any way to detect what was fullscreen, so I avoided it and posted that code ;)high key wrote:Thanks for your detailed code! But my problem is not the detection of the Res-change. The problem is, that in that moment, when I move my little window to a new position with movewindow(x,y) , the DirectX-application crashes sometimes. I think, this is because movewindow brings my own program in the foreground again. If I knew, whether there is another program running in fullscreenmode, I could suppress the movewindow-action until we are in normal mode again.
Code: Select all
SetWindowPos_(WindowID(), 0, x, y, 0, 0, #SWP_NOACTIVATE|#SWP_NOSIZE|#SWP_NOZORDER)
Code: Select all
SetWindowPos_(WindowID(), 0, x, y, 0, 0, #SWP_NOACTIVATE|#SWP_NOSIZE|#SWP_NOZORDER)
Code: Select all
x=10
y=10
Fensterid=OpenWindow(1,x,y,200,200,#PB_Window_SystemMenu,"movetest")
abstand=10
For i=1 To 1000
Delay(1000)
x+abstand
y+abstand
MoveWindow(x,y)
If x>300 Or x<10
abstand=-abstand
EndIf
Next i