Screen Saver Enabling/Disabling

H

HumptyDumpty

Does anyone know if there is a problem with re-enabling the Screen
Saver after it has been disabled programmatically.

I am using the SystemParametersInfo function within User32.dll, and
have been successful in disabling the Screen Saver, but it does not
work for re-enabling. The only way I can re-activate it is to
re-apply the settings through the Display properties in the Control
Panel.

Sample lines of code, in simplest form:

// Screen Saver disable
SystemParametersInfo( 17, 0, 0, 0);

// Screen Saver enable
SystemParametersInfo( 17, 1, 0, 0);

I have discovered there may be problems with retrieving the Active
status, but have not found any information relating to
re-activation.

Your assistance would be much appreciated.
 
G

Guy Mahieu

This is al very vague but maybe it can put you in the rught direction...

I believe I have read somewhere that when the screensaver kicks in, windows
will send a message to all running applications, so maybe you can override
the WndProc method on NativeWindow or a Form to capture that message and
work from there.

Greets..

G.

HumptyDumpty said:
Does anyone know if there is a problem with re-enabling the Screen
Saver after it has been disabled programmatically.

I am using the SystemParametersInfo function within User32.dll, and
have been successful in disabling the Screen Saver, but it does not
work for re-enabling. The only way I can re-activate it is to
re-apply the settings through the Display properties in the Control
Panel.

Sample lines of code, in simplest form:

// Screen Saver disable
SystemParametersInfo( 17, 0, 0, 0);

// Screen Saver enable
SystemParametersInfo( 17, 1, 0, 0);

I have discovered there may be problems with retrieving the Active
status, but have not found any information relating to
re-activation.

Your assistance would be much appreciated.
 
H

HumptyDumpty

Thanks Guy.

I have solved the problem with WndProc as you mentioned. The downside
is its quite an inefficient way to solve the problem.

I have since resolved the problem using the User32.dll. There does
seem to be a bug in that you cannot detect the current activeness of
the screen saver, but an alternative workaround is to use check a
registry key instead.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top