This is my first Delphi Component, so go easy on it.

You may distribute it, modify it, do anything you like to it, but please:

1) You send me a copy of the source if you improve it.
2) Leave my name in it somewhere i.e. Based on TScreenSaver by JB.
3) If you make lots of money using it, please send me some.

jon.baker@virgin.net

Use of this component is at your own liability. - Please don't call me if you:

1) Loose any data....
2) Loose any money....
3) Format your hard drive....
4) Stab your-self....

... with this Component.


There are 2 important notes at the end, which I suggest you read.

Version 2 Developments
______________________

Added AutoPanelHide function as suggested by Jim McKeeth.
This hides the config panel if specified

Added SC_Screensave message functions suggested by Ken Knight.
Should stop the screensaver from activating more than once.

Added extra functions to stop blank boxes on the taskbar.
Suggested by John F Jarrett.

Thanks Guys.

Fix problem with application not terminating after password change.

Added Event functions to MainSaver, Preview, ConfigBox, PasswordSet.
You can add your own code to activate at each of these times.
These are also triggered even if the capture is disabled.
ie. If PreviewWindow is set to False, you can still add your own code to Preview Active, to create for example your own preview.
I hope this is useful for you


Version 3 Developments
______________________


Fixed to Hook to the WM_SYSCOMMAND SC_ScreenSave message functions which finally stops the screensaver from activating more than once.

Fixed minor bugs with Preview Window and Display Properies screen.

JB


The Component.
______________


Tested with Delphi 3 & 4, might work with D2, may need some modifications.

Basically, install the component. If you don't know how to install a component, where have you been?

Drop one on the form. Just the one Mrs Wembly. - Thats a British thing.

Change the Properties.

Properties.
___________


AutoBorderLess.
	True -> In Main Screensaver Form BorderStyle will be set to bsNone automatically.
	False -> Border will be what ever you set.

AutoEnable.
	True -> Component runs when Application is run.
	False -> You will need to run it manually, using the ScreenSaver1.Enable command.
	Note: There is no disable, I did not think it would be needed as Screen saver should terminate completely.

AutoMaximize.
	True -> In Main Screensaver Form WindowStyle will be set to wsMaximized automatically.
	False -> WindowStyle will be what ever you set.
	Note: Sizing on preview window will alter if False because it is scaled by Form Width, not Screen Width.

AutoMouseHide.
	True -> In Main Screensaver cursor automatically disappears.
	False -> Cursor will not.

AutoPanelHide.
	True -> In Main/Preview Screensaver Config Panel is automatically hidden.
	False -> Panel is not.

AutoOnTop.
	True -> In Main Screensaver Form FormStyle will be set to fsStayOnTop automatically.
	False -> You got it, it will not.

ConfigurationBox.
	True -> Will handle /c or No Parameter and display the Configuration box.
	False -> Will ignore these parameters and pass control to Form.

ConfigurationBoxMessage.
	String -> If you select a MessageDlg box for the configuration box, this is the string it will use.
	Microsoft use 'This Screen Saver has not options to configure'. I use '1999 Jon Baker'.

ConfigurationBoxPanel.
	TPanel -> If you choose a panel to be displayed for your configuration box, you should choose a Panel name here.
	Note: If you delete the panel etc, the Component will automatically default to cbsMessageDlg. I hope.

ConfigurationBoxStyle.
	cbsPanel -> All panels except the one chosen in ConfigurationBoxPanel will be hidden.
	The form will than be fitted around this panel when a configuration box is called.
	cbsMessageDlg -> Will display a Message box with an OK button. Message is specified by text in ConfigurationBoxMessage.

MainScreenSaver.
	True -> When application is started with /S Component will automatically display the Main Form (Screen Saver);
	False -> This parameter will be ignored and control passed back to main form.

Name.
	Which planet are you on.

PasswordSetting.
	True -> When /A is passed it will display the Win 95 Change Screen Saver Password Dialog.
	False -> It will not.
	Note: This function is not called under NT.
	Note: I have not tested this under 98. It may work, it may not. Basically I don't care.

PreviewWindow.
	True -> When /P 12356 is passed the Component will display the preview in the Display Properties box.
	False -> It will ignore this parameter and pass control to the MainForm.
	Note: The original purpose of TScreenSaver was to do this preview, I just got carried away.

SystemKeysDisabled.
	True -> When running the main screen saver ALT-CTRL-DEL, CTRL-ESC, ATL-TAB etc will be disabled.
	False -> They will be fully functional. Not recommended, although could be useful while debugging.

Tag.
	I have no functional use for this at this time.

OnPreviewActive.
	Put any functions in here you want to run when the preview window is active.

OnMainSaverActive.
	Put any functions in here you want to run when the main screensaver is active.

OnConfigBoxActive.
	Put any functions in here you want to run when the config box is active.

OnPasswordSet.
	Put any functions in here you want to run after the password change is complete (or your own password functions if the PasswordSettings if disabled).

Important Note on Closing the Screensaver.
__________________________________________

Under Windows 95, the screensaver has to deal with its mouse keyboard events.. God bless NT etc...

Basically. You have to tell the Application to close on Mousemove, MouseDown, KeyPress etc...

The problem here is that when the Form is created it ALWAYS passes a MouseMove event, thus terminating your
screensaver before it starts.

To overcome this you could stop the application from closing on the first MouseMove.

Problem. If you put, say, a moving picture on your form then on every move a MouseMove is passed.

Solution. I solved the problem by placing a very small (20x20) blank TImage component on my Form as the top component.
This is set not to Close on MouseMove. Then I told the application that for MouseMoves in the first 25ms (1 is guaranteed) to place the Image X-10, Y-10, i.e. Centrally under the Cursor. Now when the mouse moves off the invisible Image the Form will close.


Important Note on Password Protection.
______________________________________

Under Windows 95, the screensaver has to deal with its own password protection. God bless NT etc...

Basically. To check the password before termination of the Screensaver you should do the following.

In the CloseQuery event call on the Form add the line.


If ScreenSaver1.DoPasswordCheck = False then CanClose := False;


The whole section should look like this.

procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
If ScreenSaver1.DoPasswordCheck = False then CanClose := False;
end;

If you are using the method described above to capture mouse move events, you will need to reset the timer as well.
