Archived

This topic is now archived and is closed to further replies.

czar

Screensaver killing delphiX programs?

Recommended Posts

czar    122
Hello, I have this problem that when my program written using delphiX is left sitting active on a computer for a long time then the computer often freezes and needs to be rebooted. In some case I can "wake" the computer up, if it has gone into standby mode, and I will see a "canvas does not allow drawing" message. Has anyone got any ideas on this one? I have a program running on a number of schools and some report this occuring regularily.

Share this post


Link to post
Share on other sites
Xorcist    122
That sounds like a DirectX issue in and of itself. The screen saver is most likely causing your DirectDraw surface to be lost, and you''ll need to reaquire it upon termination of the screensaver (same thing happens if you try to change the screen resolution while your DirectX app is running). What you might want to do is have your app disallow the screensaver from starting while it''s active. I know there is a way to do that, maybe a simple registry tweak, then all you have to do is reset it when your app terminates.

Share this post


Link to post
Share on other sites
czar    122
Thanks. I did a little search, found some code added a new bit and now I have a procedure that prevents the screensaver and "monitor turn off" from occuring. In my situation this is acceptable, however this solution would not be the most desirable for a commercial program. However, it works fine. I posted the code here in case someone else wants it.

type
TForm1 = class(TForm)
private
procedure WMSysCommand(var Msg : TWMSysCommand); message WM_SYSCOMMAND;

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;

Edited by - czar on November 14, 2001 4:29:59 PM

Share this post


Link to post
Share on other sites