Screensaver killing delphiX programs?

Started by
2 comments, last by czar 22 years, 5 months ago
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.
Advertisement
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.
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
Hmp, I know I''ve left projects running overnight and have not had any problems with the screen savers crashing them. Wierd.
Fitz

This topic is closed to new replies.

Advertisement