How to make windows screensaver

How to make windows screensaver

How to make windows screensaver

This Delphi graphic tutorial demonstrates how to create a simple windows screensaver. To demonstrate this we are going to put some random images on desktop.

DownloadDownload This Tutorials

Bookmark:

How to make windows screensaver

A Windows screen saver is basically just a standard Windows executable that has been renamed to have a .SCR filename extension. In order to interface properly, certain requirements must be met. In general, the program must:

  • Distinguish between active mode and configuration mode
  • Disallow multiple copies of itself to run
  • Exit when the user presses a key or moves the mouse

First, we need to be able to load and save the current configuration. To do this, we should place the Speed Interval value into an initialization file (*.INI) in the user's Windows directory. Delphi's TIniFile object is just the thing for this.

How to Make a Windows Screen Saver

Add the following uses clause to the implementation section of the configuration form's unit:

    uses
         IniFiles;

Then, add the following procedure declarations to the configuration form unit:

private
     { Private declarations }
     procedure SaveConfig(Sender: TObject);
public
     { Public declarations }
     Speed : Integer;
     procedure LoadConfig(Sender: TObject);
end;

const
     CfgFile = 'FLOWERS.INI';

procedure TFlowers_CFG_Form.LoadConfig(Sender: TObject);
var
     IniFile : TIniFile;
begin
     IniFile := TIniFile.Create(CfgFile);
     Try
     With IniFile Do
          Speed := ReadInteger('Config', 'Speed',10);
     Finally
          inifile.Free;
     End;
end;

procedure TFlowers_CFG_Form.SaveConfig(Sender: TObject);
var
     IniFile : TIniFile;
begin
     IniFile := TIniFile.Create(CfgFile);
     Try
     With IniFile Do
          WriteInteger('Config', 'Speed', Speed);
     Finally
          IniFile.Free;
     End;
end;

Load the configuration automatically

procedure TFlowers_CFG_Form.FormCreate(Sender: TObject);
begin
     { First, load the configuration automatically
     whenever the program starts up. }
     LoadConfig(Self);
     Edit1.Text := IntToStr(Speed);
end;

For screensaver form, make it transparent at startup

procedure TFlowers_SCR_Form.FormCreate(Sender: TObject);
begin
     { Set transparent background }
     Brush.Style:=bsClear;

     Timer1.Enabled := False;
end;

Download This Delphi Tutorials.

Download materials for this article (Delphi - Tutorials)

Download - flower-screensaver.zipflower-screensaver.zip
       File size: 311 KB, File type: zip
       Total downloads: 1018, Upload date: February 11 - 2009

puky :: May 18-2009 :: 09:52 AM

interesting tutorial for Delphi beginners

mohammad keshavarz :: May 08-2010 :: 07:56 AM

screen saver with delfi(code)

Leave a comment