home *** CD-ROM | disk | FTP | other *** search
/ Chip: Shareware for Win 95 / Chip-Shareware-Win95.bin / ostatni / delphi / delphi2 / wowsrc.exe / SSAVE.PAS < prev    next >
Pascal/Delphi Source File  |  1996-03-28  |  9KB  |  209 lines

  1. unit Ssave;
  2.  
  3. interface
  4.  
  5.  
  6. uses WinTypes, WinProcs, Classes, Graphics, Forms, Controls, StdCtrls,
  7.      IniFiles, SysUtils, Messages, ExtCtrls;
  8.  
  9. type
  10.   TScrn = class(TForm)
  11.     Image: TImage;                                     { True If Loading }
  12.     procedure FormKeyDown(Sender: TObject; var Key: Word;
  13.       Shift: TShiftState);
  14.     procedure FormCreate(Sender: TObject);
  15.     procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  16.       Y: Integer);
  17.     procedure FormActivate(Sender: TObject);
  18.     procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
  19.       Shift: TShiftState; X, Y: Integer);
  20.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  21.   private
  22.     ptMpos : TPoint;                                       { The mouse position }
  23.  
  24.     Procedure DoSs(Var WinMsg : TMessage);
  25.                                 message WM_USER + 1;       { Trigger Message }
  26.     Procedure GetPwd(Var WinMsg : TMessage);
  27.                                 message WM_USER + 2;       { Get The Password }
  28.     Procedure GetPassword;                                 { Get password, if any }
  29.     procedure Trigger(Sender : TObject; Var Done : Boolean);                   { On Idle Trigger }
  30.     Procedure OnTop(TopMost : Boolean);
  31.  
  32.     { Private declarations }
  33.   public
  34.     LoadingApp : Boolean;
  35.  
  36.     { Public declarations }
  37.   end;
  38.  
  39. var
  40.   Scrn: TScrn;
  41.  
  42. implementation
  43. Uses
  44.   Globals,
  45.   GetPass,
  46.   CodeMsg,
  47.   CodeBall,
  48.   CodeSpot,
  49.   Bitmap;
  50.  
  51. {$R *.DFM}
  52.  
  53. Procedure TScrn.DoSs(Var WinMsg : TMessage);               { Called by trigger to activate a display routine }
  54. Begin
  55.   Case SsType Of                                           { Work on SS Type }
  56.     1 : MoveMsg;
  57.     2 : BallDisplay;
  58.     3 : DrawSpot;
  59.     4 : MovePic;
  60.     end;
  61. end;
  62.  
  63. Procedure TScrn.GetPwd(Var WinMsg : TMessage);             { Get a password }
  64. Begin
  65.   GetPassword;                                             { Get a password }
  66. end;
  67.  
  68. Procedure TScrn.OnTop(TopMost : Boolean);                  { Set FLOATING style }
  69. Begin
  70.   if TopMost then                                          { If floating }
  71.     SetWindowPos(Handle,HWND_TOPMOST,0,0,0,0,
  72.                  SWP_NOSIZE + SWP_NOMOVE)                  { Set it }
  73.   else
  74.     SetWindowPos(Handle,HWND_NOTOPMOST,0,0,0,0,
  75.                  SWP_NOSIZE + SWP_NOMOVE);                 { No Float }
  76. End;
  77.  
  78. Procedure TScrn.GetPassword;                               { Get a Password }
  79. Var
  80.   CanExit : Boolean;                                       { True if we let them Exit }
  81. begin
  82.   Application.OnIdle := nil;
  83.   ReleaseCapture;                                          { Release the Capture }
  84.   if (TestMode) or (PwdType = 0) or
  85.      ((PwdType = 1) and (Pwd = '')) then                   { If A NO password Needed }
  86.     CanExit := True                                        { we Can Exit }
  87.   else begin
  88.     OnTop(False);                                          { Drop On Top }
  89.     CursorOn;                                              { Turn the Cursor On }
  90.     Wpwd := TWpwd.Create(Application);                     { Create the dialog }
  91.     Wpwd.ShowModal;                                        { Show the Dialog }
  92.     CanExit := Wpwd.PwdOk;                                 { Get the Result }
  93.     Wpwd.Free;                                             { Free it }
  94.     end;
  95.   if CanExit then                                          { If we can Now get out }
  96.     Close                                                  { Do So }
  97.   else begin
  98.     CursorOff;
  99.     SetCapture(Scrn.Handle);                               { Capture the Cursor }
  100.     SetFocus;                                              { Reset focus to the Screen }
  101.     OnTop(True);
  102.     Application.OnIdle := Trigger;                         { Set the OnIdle Proc }
  103.     end;
  104. end;
  105.  
  106. procedure TScrn.Trigger(Sender : TObject; Var Done : Boolean);                 { Called when Delphi gets bored }
  107. begin
  108.   PostMessage(Handle,WM_USER + 1,0,0);                     { Move it, and trigger again }
  109. end;
  110.  
  111.  
  112. procedure TScrn.FormKeyDown(Sender: TObject;
  113.                             var Key: Word;
  114.                             Shift: TShiftState);
  115. begin
  116.   GetPassword;                                             { Get the Password }
  117. end;
  118.  
  119. procedure TScrn.FormMouseMove(Sender: TObject;
  120.                               Shift: TShiftState;
  121.                               X,  Y: Integer);
  122. begin
  123.   if (ptMpos.X = -1) and (ptMpos.Y = -1) then begin        { If the mouse has moved }
  124.     ptMpos.X := X;                                         { Grab the X }
  125.     ptMpos.Y := Y;                                         { Grab the Y }
  126.     end
  127.   else if (Abs(X - ptMpos.X) > 2) and
  128.           (Abs(Y - ptmPos.Y) > 2) then Begin               { if a move > 2 pixels }
  129.     ptMpos.X := X;                                         { Grab the New X }
  130.     ptMpos.Y := Y;                                         { Grab the New Y }
  131.     GetPassword;                                           { Get the Password }
  132.     end;
  133. end;
  134.  
  135.  
  136. procedure TScrn.FormCreate(Sender: TObject);
  137. begin
  138.   LoadingApp := True;                                         { We are Loading }
  139. end;
  140.  
  141. procedure TScrn.FormActivate(Sender: TObject);
  142. begin
  143.   If LoadingApp then begin                                    { If Loading }
  144.     LoadingApp := False;                                      { Reset Flag }
  145. (*    Scrn.Visible := False;*)
  146.     If not DelayInit then Delay(0);                        { If delay NOT done then init }
  147.     
  148.     if Not TestMode then ReadDefaults;                     { Read the Defaults }
  149.     ptMpos.X := -1;                                        { Reset mouse X }
  150.     ptMpos.Y := -1;                                        { Reset Mouse Y }
  151.     ScreenWd := Screen.Width;                              { Set GLOBAL Screen Ht }
  152.     ScreenHt := Screen.Height;                             { Set GLOBAL Screen Width }
  153.  
  154.     case SsType of                                         { No based on the Type of the Saver .... }
  155.       1 : Begin                                            { Message }
  156.           InitMessage;                                     { Init }
  157.           Scrn.Color := BkGrnd;                            { Set the Screen background }
  158.           OnTop(True);                                     { Stay On Top }
  159.           end;
  160.       2 : Begin
  161.           InitBalls;                                       { Init Spheres }
  162.           Scrn.Color := clBlack;                           { Set the Screen background }
  163.           end;
  164.       3 : Begin
  165.           InitSpot;                                        { Init Spot }
  166.           Scrn.Color := clBlack;                           { Set the Screen background }
  167.           end;
  168.       4 : Begin                                            { Bitmap }
  169.           InitPicture;                                     { Init }
  170.           Scrn.Color := BkGrnd;                            { Set the Screen background }
  171.           OnTop(True);                                     { Stay On Top }
  172.           end;
  173.  
  174.       end;
  175.     Scrn.Top := 0;                                         { Set top }
  176.     Scrn.Left := 0;                                        { Set Left }
  177.     Scrn.Width := ScreenWd;                                { Full Screen }
  178.     Scrn.Height := ScreenHt;                               { Full Screen }
  179.     OnTop(True);                                           { Set on Top }
  180.     CursorOff;                                             { Turn the Cursor Off }
  181.     Application.OnIdle := Trigger;                         { Set the OnIdle Proc }
  182.     Scrn.Visible := True;                                  { Make It Visible }
  183.     SetCapture(Scrn.Handle);                               { Capture the Mouse }
  184.   end;
  185. end;
  186.  
  187.  
  188. procedure TScrn.FormMouseDown(Sender: TObject;
  189.                               Button: TMouseButton;
  190.                               Shift: TShiftState;
  191.                               X, Y: Integer);
  192. begin
  193.   GetPassword;                                             { Get Password }
  194. end;
  195.  
  196. procedure TScrn.FormClose(Sender: TObject; var Action: TCloseAction);
  197. begin
  198.   Application.OnIdle := nil;                               { Loose the trigger }
  199.   CursorOn;                                                { Set the Cursor On }
  200.   Case SsType of
  201.     1 : FreeMsg;
  202.     2 : FreeBalls;
  203.     3 : FreeSpot;                                          { Free if required }
  204.     4 : FreePic;
  205.     end;
  206. end;
  207.  
  208. end.
  209.