Solved

screensaver keeps running when I select it

Posted on 1997-08-26
7
313 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 50 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

740 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