home *** CD-ROM | disk | FTP | other *** search
/ Chip: Shareware for Win 95 / Chip-Shareware-Win95.bin / ostatni / delphi / delphi2 / wowsrc.exe / CODEMSG.PAS < prev    next >
Pascal/Delphi Source File  |  1995-10-28  |  6KB  |  118 lines

  1. unit Codemsg;
  2.  
  3. interface
  4. Uses
  5.   Graphics, StdCtrls;
  6.  
  7. Var
  8.   BitMsg : TBitmap;                                        { Bitmap of the Message }
  9.   Msg    : TLabel;                                         { Label ( created on the Fly }
  10.  
  11. Procedure MoveMsg;                                         { Move the Message }
  12. Procedure InitMessage;                                     { Startup }
  13. Procedure FreeMsg;                                         { Free any resources }
  14. Procedure ReadMsgDefaults;                                 { Read any defaults }
  15.  
  16. implementation
  17. Uses
  18.   Globals,
  19.   Ssave,
  20.   IniFiles;
  21.  
  22. Procedure ReadMsgDefaults;                                 { Read Defaults }
  23. Var
  24.   Ini   : TiniFile;
  25.   Fnt   : Integer;                                         { Font }
  26.   Style : TFontStyles;                                     { Font Styles }
  27. Begin
  28.   Ini := TIniFile.Create('Wow.Ini');                   { Open the Ini File }
  29.   MsgFont := TFont.Create;                                 { Create Font }
  30.   Apptitle := 'Screen Saver.Delphi Message';               { Set title }
  31.   MsgFont.Name := Ini.ReadString(AppTitle,
  32.                                  'FontName',               { Read Font Name }
  33.                                  'Arial');
  34.   MsgFont.Size := Ini.ReadInteger(AppTitle,
  35.                                  'FontSize',
  36.                                  8);                       { Read Font Size }
  37.   MsgFont.Height := Ini.ReadInteger(AppTitle,
  38.                                  'FontHeight',
  39.                                  -13);                     { Read Font Height }
  40.   MsgFont.Color := Ini.ReadInteger(AppTitle,
  41.                                    'FontColour',
  42.                                    Ord(clWhite));          { Read Colour }
  43.   Fnt := Ini.ReadInteger(AppTitle,
  44.                          'FontStyle',
  45.                          0);                               { Read the Style }
  46.   Style := [];
  47.   if Fnt and 1 = 1 then Include(Style,fsBold);             { Check Bold }
  48.   if Fnt and 2 = 2 then Include(Style,fsItalic);           { Check Italic }
  49.   if Fnt and 4 = 4 then Include(Style,fsUnderline);        { Check Underline }
  50.   if Fnt and 8 = 8 then Include(Style,fsStrikeOut);        { Check strikout }
  51.   MsgFont.Style := Style;                                  { Set the Style }
  52.  
  53.   BkGrnd := Ini.ReadInteger(Apptitle,
  54.                             'BkGrnd',
  55.                             Ord(clBlack));                 { Get the background colour }
  56.   MsgText := Ini.ReadString(Apptitle,
  57.                             'Msg',
  58.                             'The Pack Is Back!') + ' '; { Get the Text }
  59.   Speed := Ini.ReadInteger(Apptitle,
  60.                            'Speed',25);                    { Get the Speed }
  61.   CntrText := Ini.ReadBool(AppTitle,
  62.                            'Centered',
  63.                            True);                          { Get Centered }
  64.   Fg := Ini.ReadInteger(AppTitle,'Fg',15);                 { Read The Foreground Color }
  65.   Bg := Ini.ReadInteger(AppTitle,'Bg',0);                  { Read The Background Color }
  66.   PwdType := Ini.ReadInteger(AppTitle,
  67.                              'PwdType',0);                 { Get Pwd Type }
  68.   Pwd := Ini.ReadString('ScreenSaver',
  69.                         'Password',
  70.                         '');                               { Read the Password, if any }
  71. end;
  72.  
  73. procedure InitMessage;
  74. begin
  75.   ReadMsgDefaults;                                         { Read the Default Settings }
  76.   Msg := TLabel.Create(Scrn);                              { Create the Label }
  77.   Msg.Parent := Scrn;                                      { Set Parent }
  78.   Msg.Visible := False;                                    { Set Visible }
  79.   Msg.Caption := MsgText;                                  { Get the Text }
  80.   Msg.Font := MsgFont;                                     { Set the Font }
  81.   iObjL := ScreenWd;                                       { Start with Message a Right edge }
  82.   iObjR := ScreenWd + Msg.Width;                           { Grab the width }
  83.   iObjT := (ScreenHt - Msg.Height) Div 2;                  { Set Message top to MID screen }
  84.   BitMsg := TBitmap.Create;                                { Create the Bitmap }
  85.   BitMsg.Width := Msg.Width;                               { Set width to Message Width }
  86.   BitMsg.Height := Msg.Height;                             { Set Height to Message Height}
  87.   with BitMsg.Canvas do begin                              { Now transfer the Message to the bitmap }
  88.     Brush.Color := BkGrnd;                                 { Background to default }
  89.     Font := Msg.Font;                                      { Grab the Message Font }
  90.     TextOut(0,0,Msg.Caption);                              { Wack the Text in }
  91.     end;
  92. end;
  93.  
  94. Procedure FreeMsg;
  95. Begin
  96.   BitMsg.Free;                                             { Free the Bitmap }
  97.   Msg.Free;                                                { Free the Bitmap }
  98. end;
  99.  
  100. Procedure MoveMsg;
  101. Begin
  102.   Dec(iObjL,1);                                            { Move Left }
  103.   Dec(iObjR,1);                                            { Adjust RIGHT }
  104.   if iObjR < 0 then begin                                  { if OFF screen }
  105.     if Not CntrText then begin                             { If not Centered }
  106.       iObjT := Random(Scrn.Height);                        { Get new Random position }
  107.       if iObjT + Msg.Height > ScreenHt then                { if we are off the Screen }
  108.         iObjT := ScreenHt - Msg.Height;                    { Move back on again }
  109.       end;
  110.     iObjL := ScreenWd;                                     { Reset the RIGHT edge }
  111.     iObjR := iObjL + Msg.Width;                            { Reset R margin }
  112.     end;
  113.   Scrn.Canvas.Draw(iObjL,iObjT,BitMsg);                    { Draw the Message }
  114.   Delay(Speed);                                            { Delay a Bit }
  115. end;
  116.  
  117. end.
  118.