Solved

screensaver keeps running when I select it

Posted on 1997-08-26
7
316 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

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…
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month3 days, 11 hours left to enroll

630 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