How do I know, if a screensaver is running?
How do I know, if a screensaver is running?
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?
- tinman
- PureBasic Expert

- Posts: 1102
- Joined: Sat Apr 26, 2003 4:56 pm
- Location: Level 5 of Robot Hell
- Contact:
Re: How do I know, if a screensaver is running?
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?
If you paint your butt blue and glue the hole shut you just themed your ass but lost the functionality.
(WinXPhSP3 PB5.20b14)
(WinXPhSP3 PB5.20b14)
My program isn't fullscreen
It's a little window with the actual date and time in it. I want, that this window changes its position, if the screenresolution is changed. That works fine most time. But when starting a DirectX-game, there are sometimes fatal faults (which do not occur, if my date&time program isn't running)
- tinman
- PureBasic Expert

- Posts: 1102
- Joined: Sat Apr 26, 2003 4:56 pm
- Location: Level 5 of Robot Hell
- Contact:
This code seems to work, although I only tested it by changing my desktop resolution and running the directX test programs. I did not have any errors, so there is no code there to test whether the screen is active or not. What kind of games and screen output are you doing in your own code?
(PS, creating strings in the callback is probably a bad thing to do, but this is just an example :)
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
If you paint your butt blue and glue the hole shut you just themed your ass but lost the functionality.
(WinXPhSP3 PB5.20b14)
(WinXPhSP3 PB5.20b14)
The Res-change is not the problem :-)
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.
- tinman
- PureBasic Expert

- Posts: 1102
- Joined: Sat Apr 26, 2003 4:56 pm
- Location: Level 5 of Robot Hell
- Contact:
Re: The Res-change is not the problem :-)
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.
If you think it is related to MoveWindow you could try using the SetWindowPos_() command from the Win32 API. You will get more control over the way the window is moved. Something like this will move only the X and Y position but not anything else:
Code: Select all
SetWindowPos_(WindowID(), 0, x, y, 0, 0, #SWP_NOACTIVATE|#SWP_NOSIZE|#SWP_NOZORDER)
If you paint your butt blue and glue the hole shut you just themed your ass but lost the functionality.
(WinXPhSP3 PB5.20b14)
(WinXPhSP3 PB5.20b14)
Sounds good :-)
Code: Select all
SetWindowPos_(WindowID(), 0, x, y, 0, 0, #SWP_NOACTIVATE|#SWP_NOSIZE|#SWP_NOZORDER)
That sounds really good, especially the SWP_NOACTIVATE !!!
I will try this!
Perfect :-))
Supiiiiiiieee, it worx!!! No more crashes!!! Merci beaucoup 
Grrrr, it crashed again
Last night, it seemed, the problem was found and solved, but today - same error as before 8O
I'm now quite sure, that is was not the movewindow(x,y)-command, which makes problems.
This shows, that the movewindow-command doesn't activate the moved window or brings it in front. Hence this command should not make any problems or errrors.
Perhaps the problem is in the crashing game itself (bestfriends from retro64.com) or in my graphics card / drivers? Fortunately the game crashes only once a day, when started again it runs without problems.
I'm now quite sure, that is was not the movewindow(x,y)-command, which makes problems.
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
Perhaps the problem is in the crashing game itself (bestfriends from retro64.com) or in my graphics card / drivers? Fortunately the game crashes only once a day, when started again it runs without problems.
