PDA

View Full Version : Screen Saver and UndelphiX



nzo2
05-06-2007, 09:50 PM
Doubt I`ll get an answer, but what the hell.

Seems like you can't prevent the screensaver from kicking in once DelphiX is operating in fullscreen mode. The code is fine for windowed, but not full screen.

Anyone defeated this?

czar
05-06-2007, 10:11 PM
Yes you can - have a search this topic has been answered before

nzo2
05-06-2007, 11:12 PM
I don`t see it - can you help me?

czar
05-06-2007, 11:54 PM
http://www.pascalgamedevelopment.com/viewtopic.php?t=3963&highlight=wmsyscommand

have a look there

This is what I use - but more info in the thread


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

// SWITCH OFF THE SCREENSAVER AND THE MONITOR POWER SAVER IF THEY TRY TO CUT IN
procedure TForm1.WMSysCommand(var Msg : TWMSysCommand);
begin
//catch the message and turn it off
if (Msg.CmdType = SC_MONITORPOWER) or (Msg.CmdType = SC_SCREENSAVE) then
begin
Msg.Result := -1;
end
else
inherited;///Otherwise do whatever is supposed to be done
end;

FNX
06-06-2007, 07:49 AM
Same solution here:
http://www.swissdelphicenter.ch/torry/showcode.php?id=344

nzo2
07-06-2007, 06:55 PM
Same solution here:
http://www.swissdelphicenter.ch/torry/showcode.php?id=344

I have tried this one already (and slight variations of)
This solution doesn't work. The message is intercepted correctly, but the screensaver fires nonetheless.

Maybe the secret lies in Czar's extra result setting - will try now..

nzo2
07-06-2007, 07:17 PM
http://www.pascalgamedevelopment.com/viewtopic.php?t=3963&highlight=wmsyscommand

have a look there

This is what I use - but more info in the thread


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



How is this proc suppose to be called? It won't plug onto the application.OnMessage....

czar
07-06-2007, 07:26 PM
Put this

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

in your form private - add the routine and bob's your uncle.

Works for us - and we have this code used in hundreds of programs

nzo2
07-06-2007, 10:42 PM
This is very strange. The condition is met and and the msg.result is set, but the screensaver still activates...

Is there any other factor that I need to consider?

savage
08-06-2007, 07:12 AM
I thought the

Msg.Result := -1;

should actually be

Msg.Result := 0;

meaning handled, therefore it won't power off. Have you tried changing the result to zero?

nzo2
09-06-2007, 12:14 AM
Screen saver still activates with Msg.Result:=0

savage
09-06-2007, 10:53 AM
Screen saver still activates with Msg.Result:=0

What are you using to test if this code works? Using ScreenSaver Preview will not generate a SC_SCREENSAVE message, but if you set your screen saver timeout to 1 minute and wait, it will and you will see that the screensaver does not kick in. I know because I just tried it.

nzo2
09-06-2007, 04:58 PM
It isn`t using a screensaver preview. I let the screensaver kick in. The SC_SCREENSAVE message is generated and is intercepted. However, the screensaver still runs.

savage
09-06-2007, 05:03 PM
Really?? On my Windows XP machine using Delphi 7 it works as advertised.

Can you post the full form code you are using?

nzo2
09-06-2007, 08:21 PM
Here we are. Just tried this and the screensaver kicked in as normal...
The form is "default" as in File => New Project


unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;

type
TForm1 = class(TForm)
private
{ Private declarations }
procedure WMSysCommand(var Msg : TWMSysCommand); message WM_SYSCOMMAND;
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

procedure TForm1.WMSysCommand(var Msg : TWMSysCommand);
begin
if (Msg.CmdType = SC_MONITORPOWER) or (Msg.CmdType = SC_SCREENSAVE) then
begin
Msg.Result:=0;
end
else
inherited;
end;


{$R *.DFM}

end.

savage
09-06-2007, 08:44 PM
That is, line for line, exactly the code I used and it works fine for me.

Is the Screen Saver a default Windows one? I know I'm grasping at straws here, but it's the only thing I can think of.

nzo2
10-06-2007, 12:42 PM
yes, just the XP logo. Only thing different is it is password enabled.

savage
10-06-2007, 01:04 PM
Where do I set a screen saver password? I can't seem to find the option.

nzo2
10-06-2007, 02:10 PM
where you set the timeout, checkbox for onresume, password protected

savage
10-06-2007, 05:31 PM
Hmm I don't have a password option, though I have seen it on other systems. If you remove your password protection, does it still start the screen saver?

nzo2
10-06-2007, 08:03 PM
With the password disabled, it prevents the screensaver from working correctly. Must be a special case when the screensaver is passworded - as in a potential security risk?

savage
10-06-2007, 08:11 PM
Must be a special case when the screensaver is passworded - as in a potential security risk?

Sounds feasible. Glad that it at least works finally.

nzo2
11-06-2007, 12:05 AM
Well, I think it's always worked, but there doesn't appear to be a case where it works with a passworded screensaver.

Guess there's no way around that one.