Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2005 Jul : Trapping SC_SCREENSAVE when app has no focus

www.cryer.info
Managed Newsgroup Archive

Trapping SC_SCREENSAVE when app has no focus

Subject:Trapping SC_SCREENSAVE when app has no focus
Posted by:"Wiggum" (wiggum..@hotmail.com)
Date:5 Jul 2005 01:32:30

I need to trap the WM_COMMAND/SC_SCREENSAVE message to detect when a screen saver will launch.

The following code will work fine, but one when the application has the focus:

procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;
  var Handled: Boolean);
begin
  Handled := FALSE;
  case Msg.Message of
    WM_SYSCOMMAND :
      if Msg.wParam = SC_SCREENSAVE then
        Handled := TRUE; // disable startup of screensavers
  end;
end;

But how can I trap this message when the application
does not have the focus?

Replies:

www.cryer.info
Managed Newsgroup Archive