Solved

screensaver keeps running when I select it

Posted on 1997-08-26
7
308 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Memory leak using records in a TVirtualStringTree 11 109
PDF library for Delphi 2 104
Delphi - replicating a form 8 62
Performance of SQL statement 37 97
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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

914 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now