Multimidia - desabilitando screen saver

Top  Previous  Next

//Desabilitar screen saver:

 

function ScreenSaver(AEnabled: Boolean): Boolean;

var

  Flag: byte;

begin

  if AEnabled then

    Flag := 1

  else

    Flag := 0

 

  Result := SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, Flag, nil, 0);

end;

---------------------------------------------------------------------------------

                               2º MANEIRA

---------------------------------------------------------------------------------

//First, in the Public declaration section of your form, add the following: 

 

     Public

       procedure AppMessage(var Msg: TMsg; var bHandled : boolean);

   

//Then, in the implementation section, implement the procedure as follows: 

 

     procedure TForm1.AppMessage(var Msg: TMsg; var bHandled: boolean);

     begin

       if ((WM_SYSCOMMAND = Msg.Message) and (SC_SCREENSAVE = Msg.wParam)) then

         bHandled := True;

     end;

 

---------------------------------------------------------------------------------

                               3º MANEIRA

---------------------------------------------------------------------------------

  private

    procedure WMSysCommand(var Msg : TWMSysCommand); message WM_SYSCOMMAND;

 

procedure TForm1.WMSysCommand(var Msg: TWMSysCommand);

begin

  if ((Msg.CmdType and $FFF0) = SC_SCREENSAVE) and CheckBox1.Checked then

  // indica que processou a mensagem

  // desabilita o screen saver

    Msg.Result := 0

  else

    inherited;

end;