View Full Version : Screen Saver and UndelphiX
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?
Yes you can - have a search this topic has been answered before
I don`t see it - can you help me?
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;
Same solution here:
http://www.swissdelphicenter.ch/torry/showcode.php?id=344
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..
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....
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
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?
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.
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?
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.
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.
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?
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.
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.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.