Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

screensaver keeps running when I select it

Posted on 1997-08-26
7
Medium Priority
?
320 Views
Last Modified: 2010-04-06
I created a simple screensaver which is nothing but a blank window. I am struggling to figure out how this works, as help doesn't seem to cover any of this.  If the prog is called test.scr (and it ends with a button click for example), and I select it from display-screensavers then use the arrow to select "test.scr", it doesn't actually display in the little "test screen window in the box", but pops open and then keeps running?  If I push a button to end it, it opens and runs again...and again.....and again...... make sense?  What am I doing wrong with this?  
                  Thanks,
                     jexd99@aol.com
0
Comment
Question by:jexd99
  • 5
  • 2
7 Comments
 
LVL 8

Accepted Solution

by:
ZifNab earned 100 total points
ID: 1342565
Hi jexd99,
Can't say what you're doing wrong, because I don't have your code to look at. But I've made it myself (screensaver with blank form) and it works. I've used the code of Pablo Pizzanetsky and reduced it very much. Hope it works now. If not, give a sign! Here's the code :

{Source code for project (Project source code)}

program ScrSaver;

uses
  Forms,
  uScrSaver in 'uScrSaver.pas' {Form1},
  SysUtils;


{$R *.RES}

begin
  if ( ParamCount > 0 ) then
    begin
      if ( UpperCase( ParamStr( 1 ) ) = '/S' ) then
        begin
          Application.Initialize;
          Application.CreateForm(TForm1, Form1);
  Application.Run;
        end;
    end;
end.

{Source code for form1 : uScrSaver}

{--------------------------------------------------}
{ Screensaver blank form.                          }
{ First code : Pablo Pizzanetsky                   }
{ Reduced code for clearer look at screensaver     }
{--------------------------------------26/08/97----}


unit uScrSaver;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls , Grids, Buttons, ExtCtrls;

type

  TForm1 = class(TForm)
    procedure FormShow(Sender: TObject);
  private
    Done : Boolean;
    crs  : TPoint;
    procedure DeactivateScrnSaver(var msg : TMsg; var handled : boolean);
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}


procedure TForm1.FormShow(Sender: TObject);
begin
  GetCursorPos( crs );
  ShowCursor( False );
  WindowState := wsMaximized;
  Application.OnMessage := DeactivateScrnSaver;   {If there is a message for screensaver
                                                   go to DeactivateScrnSaver}
  try
  while not Done do begin
   {Loop until person deactivates screen}
   Application.ProcessMessages;    {Make sure windows can respond to messages}
  end;
  Close;
  except
  end;
end;


procedure Tform1.DeactivateScrnSaver(var msg : TMsg; var handled : boolean);
begin
  if Done then
    Exit;
  if msg.message = WM_MOUSEMOVE then
    done := (Abs(LOWORD(msg.lParam) - crs.x) > 5) or
            (Abs(HIWORD(msg.lParam) - crs.y) > 5)
  else
    done := (msg.message = WM_KEYDOWN)     or (msg.message = WM_KEYUP)       or
            (msg.message = WM_SYSKEYDOWN)  or (msg.message = WM_SYSKEYUP)    or
            (msg.message = WM_ACTIVATE)    or (msg.message = WM_NCACTIVATE)  or
            (msg.message = WM_ACTIVATEAPP) or (msg.message = WM_LBUTTONDOWN) or
            (msg.message = WM_RBUTTONDOWN) or (msg.message = WM_MBUTTONDOWN);
  if done then
    begin
      Close;
      raise EFOpenError.Create( 'Done' );
    end;
end;

end.

-> Just start a new application, and copy these lines
-> Questions, just ask!

Have fun,
c.u. ZifNab.

Let me now when your dazzling screensaver works!
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1342566
Hi jexd99,

Some general information for programming a screensaver if you don't already know it. (from Lloyd's Help File)


Here is the idea:  

a) In the project file (*.dpr) add '{$D SCRNSAVE <saver name>} after the uses clause.

b) On the main form, turn off the border and icon controls. In the  activate method set the form left and top to 0, and set the WindowState  to wsMaximize.

c) In the form create method, set the application.OnMessage event to a method  that controls the deactivation of the screen saver. Set the  application.OnIdle method to whatever display method for the saver.

d) In the form create method the command line should be tested for /c and  /s. These are the command line parameters windows uses to define whether  the screensaver should run or configure. (/c is for configuration)

e) Compile the program, and rename the .exe to .scr. Move it to the windows directory, and it should show up in the control panel.

{ This code came from Lloyd's help file! }
0
 

Author Comment

by:jexd99
ID: 1342567
Thanks for the info.  I will make sure all the tips listed fall into place on this thing......... hopefully one of those is causing the problem. :)
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 8

Expert Comment

by:ZifNab
ID: 1342568
Didn't my work? It worked on my machine.

Have fun,
c.u. ZifNab;


0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1342569
Sorry forgot a word,

Didn't my -> code <- work?

Have fun,
c.u. ZifNab;
0
 

Author Comment

by:jexd99
ID: 1342570
Yup, I got it to work.  It appears that the "paramstr" on mine was causing the bulk of the problems.  At least I'm over the major hurdle of getting the program to at least run! :)
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1342571
Well, glad to hear.

Hope you'll have fun desining the screensaver. Make something of it! And I hope you don't have such a bad day as I had today. Ever heard about a bug in Quickreport 1.1 ???
Well, I 'm going home and to bed and I hope tomorrow, euhm about a few hours :-) will bring me more luck.

Have fun,
c.u. ZifNab;
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

783 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question