Solved

screensaver keeps running when I select it

Posted on 1997-08-26
7
306 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 8

Expert Comment

by:ZifNab
Comment Utility
Didn't my work? It worked on my machine.

Have fun,
c.u. ZifNab;


0
 
LVL 8

Expert Comment

by:ZifNab
Comment Utility
Sorry forgot a word,

Didn't my -> code <- work?

Have fun,
c.u. ZifNab;
0
 

Author Comment

by:jexd99
Comment Utility
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
Comment Utility
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

772 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

11 Experts available now in Live!

Get 1:1 Help Now