DX causing monitor not to sleep?

Started by
5 comments, last by jasonsa 18 years, 3 months ago
Hey all, does anyone know of any link between directx and windows NOT sending a WM_SYSCOMMAND / SC_MONITORPOWER? i'm creating a screensaver and watching for these signals. When i run my app in openGL mode the monitor will turn off at the right time, but when in DX8.1 mode windows never seems to send the SC_MONITORPOWER message. If i bypass the pd3dDevice->Present() then it DOES send that message and my monitor goes to sleep. Any ideas? thanks very much, alan
Alan Kapler, Developer of Dream Aquarium www.dreamaquarium.comhref=http://www.spiralmonkey.com>www.spiralmonkey.com
Advertisement
Direct3D injects its own window procedure during fullscreen operation. Perhaps it's eating power-saving messages even though it shouldn't - that'd be a bug. Set your own window procedure again after going fullscreen, and make sure you call Direct3D's window procedure from your own somewhere (either at the beginning of your window procedure, or instead of DefWindowProc in the end - I'm not sure).

There used to be an article on MSDN about a screensaver framework using DX8. I can't find the article, so it may have be sacrificed to the gods of progress. The download containing the code sample seems to still be there though.

http://www.microsoft.com/downloads/details.aspx?FamilyID=b2886b0b-009b-4007-96c8-5e993d2cf0bb&DisplayLang=en
Stay Casual,KenDrunken Hyena
Well, i found the problem. A while ago i changed my screensaver from ending in .scr to ending in .exe. It turns out, if i run the .exe version, it never receives a SC_MONITORPOWER signal, but if i merely rename it to .scr, it does get the signal. This only happens when i run it in Direct3D mode.

anybody know of a possible reason for this?

thanks,
alan
Alan Kapler, Developer of Dream Aquarium www.dreamaquarium.comhref=http://www.spiralmonkey.com>www.spiralmonkey.com
Quote:Original post by spiralmonkey
anybody know of a possible reason for this?

Since that behavior distinctly changed after you altered the exe to a screensaver extension, it must be some behavior built into Windows or the D3D runtime. Perhaps they never want normal, fullscreen D3D apps to sleep, while they think its ok for screensavers to.
Dustin Franklin ( circlesoft :: KBase :: Mystic GD :: ApolloNL )
I wonder if it isn't a hack that was put in place to protect badly written D3D apps from dying when the screensaver kicks in. I know there used to be a LOT of those. Quite a few even mentioned in the ReadMe that you should disable the any screensavers before playing the games.

I really hate hacks like that, but I grudgingly admit the neccessity for them.
Stay Casual,KenDrunken Hyena
D3D should not be interfering in screensaver policy -- not sure why you're seeing what your seeing.

However, the correct way to disable the screensaver is to call this API:

SetThreadExecutionState(ES_MONITOR_REQUIRED);


This was recently changed in DXUT. For a long time, DXUT incorrectly used SC_MONITORPOWER but this isn't the right way to disable screensavers.

Jason
DirectX SDK Dev Lead

This topic is closed to new replies.

Advertisement