DelphiFAQ Home Search:

Temporarily disable the screensaver

 

commentsThis article has not been rated yet. After reading, feel free to leave comments and rate it.

You can control the screen-saver from your Delphi application by intercepting the system message SC_SCREENSAVE.
The following piece of code disables the screen-saver as long as your application runs:

procedure TForm1.AppMessage(var Msg: TMsg; var Handled: Boolean);
begin
  if (Msg.message = WM_SYSCOMMAND) and (Msg.wParam = SC_SCREENSAVE) then
  begin
    Msg.wParam := 0;
    Msg.message := sc_Move;
    Handled := true;
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Application.OnMessage := AppMessage; { set the message handler }
  // .. other stuff
end;

Comments:

2007-02-19, 14:56:51
anonymous from Brazil  
It appears only works in Window 9x.

I've tested on Win 9x machines and it works fine.
But it had no effect on Windows NT, 200 or XP.
(I didn't make any test on a Windows 2003 server,
but I think the result will be same as on 2000 or XP).

Quantum.

 

 

Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option.
 
It seems that you are
from Los Angeles, US .

Info/ Feedback on this

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:
photo Add a picture:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity. The owner of this web site reserves the right to delete such material.