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.
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.
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)
flower-screensaver.zip
File size: 311 KB, File type: zip
Total downloads: 1175, Upload date: February 11 - 2009
puky :: May 18-2009 :: 01:52 PM
interesting tutorial for Delphi beginners
mohammad keshavarz :: May 08-2010 :: 11:56 AM
screen saver with delfi(code)