unit uScreen;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, MPlayer;
type
TFmMediaScreen = class(TForm)
MediaPlayer: TMediaPlayer;
procedure FormDestroy(Sender: TObject);
procedure MediaPlayerNotify(Sender: TObject);
procedure FormKeyDown(Sender: TObject
var Key: Word;
Shift: TShiftState);
procedure FormMouseDown(Sender: TObject
Button: TMouseButton;
Shift: TShiftState
X, Y: Integer);
procedure FormMouseMove(Sender: TObject
Shift: TShiftState
X,
Y: Integer);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject
var Action: TCloseAction);
private
FFileList : TStrings;
FIndex : Integer;
FOldMousePos : TPoint;
public
{ Public declarations }
end;
var
FmMediaScreen: TFmMediaScreen;
implementation
uses
uConfig;
{$R *.dfm}
procedure TFmMediaScreen.FormDestroy(Sender: TObject);
begin
FFileList.Free;
end;
procedure TFmMediaScreen.MediaPlayerNotify(Sender: TObject);
begin
if MediaPlayer.Position >= MediaPlayer.Length then
begin
if FIndex = FFileList.Count - 1 then
FIndex := 0
else
Inc(FIndex);
MediaPlayer.Notify := False;
MediaPlayer.Close;
MediaPlayer.FileName := FFileList.Strings[FIndex];
if FileExists(MediaPlayer.FileName) then
begin
MediaPlayer.Display := Self
MediaPlayer.Open;
MediaPlayer.Display := Self;
MediaPlayer.DisplayRect := ClientRect;
MediaPlayer.Notify := True;
MediaPlayer.Play;
end;
end;
end;
procedure TFmMediaScreen.FormKeyDown(Sender: TObject
var Key: Word;
Shift: TShiftState);
begin
if not ((ParamCount > 0) and (Uppercase(ParamStr(1)) = '/P')) then
Close;
end;
procedure TFmMediaScreen.FormMouseDown(Sender: TObject;
Button: TMouseButton
Shift: TShiftState
X, Y: Integer);
begin
if not ((ParamCount > 0) and (Uppercase(ParamStr(1)) = '/P')) then
Close
else begin
if Button = mbRight then
begin
if FIndex = 0 then
FIndex := FFileList.Count - 2
else
FIndex := FIndex - 2;
end;
if MediaPlayer.Mode in [mpPlaying] then
MediaPlayer.Position := MediaPlayer.Length
end;
end;
procedure TFmMediaScreen.FormMouseMove(Sender: TObject
Shift: TShiftState;
X, Y: Integer);
var
NewPos : TPoint;
begin
if not ((ParamCount > 0) and (Uppercase(ParamStr(1)) = '/P')) then
begin
GetCursorPos(NewPos);
if Abs(NewPos.X - FOldMousePos.X) + Abs(NewPos.Y - FOldMousePos.Y) > 3 then
Close;
end;
end;
procedure TFmMediaScreen.FormCreate(Sender: TObject);
var
FileName : String;
aRect : TRect;
aHandle : THandle;
begin
Width := Screen.Width;
Height := Screen.Height;
FFileList := TStringList.Create;
FileName := GetexecDir + '/ScreenSaverFiles.txt';
GetCursorPos(FOldMousePos);
if (ParamCount > 0) and (Uppercase(ParamStr(1)) = '/P') then
begin
aHandle := StrToInt(ParamStr(2));
Windows.SetParent(Handle, aHandle);
Windows.GetClientRect(aHandle, aRect);
SetWindowPos(Handle, HWND_TOP, 0, 0, aRect.Right, aRect.Bottom,
SWP_SHOWWINDOW);
end
else
ShowCursor(False);;
if FileExists(FileName) then
begin
FFileList.LoadFromFile(FileName);
if FFileList.Count > 0 then
begin
MediaPlayer.Display := Self;
MediaPlayer.FileName := FFileList.Strings[0];
if FileExists(MediaPlayer.FileName) then
begin
MediaPlayer.Notify := False;
MediaPlayer.Open;
MediaPlayer.DisplayRect := ClientRect;
FIndex := 0;
MediaPlayer.Notify := True;
MediaPlayer.Play;
end;
end;
end;
//Visible := True;
end;
procedure TFmMediaScreen.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
if MediaPlayer.Mode in [mpPlaying] then
begin
MediaPlayer.Stop;
//MediaPlayer.Close;
end;
end;
end.