home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-386-Vol-2of3.iso / c / cbsdk10.zip / LINES.PAS < prev    next >
Pascal/Delphi Source File  |  1992-12-01  |  4KB  |  160 lines

  1. Library Lines;
  2.  
  3. {define Debug}
  4.  
  5. {$ifndef Debug}
  6. {$R-,I-,D-,L-,S-,V-,W-,G+}
  7. {$endif}
  8.  
  9. {$R LINES}
  10.  
  11. Uses
  12.   WinTypes,WinProcs,Strings,WinDOS;
  13.  
  14. {$I ADD-IN.INC}
  15.  
  16. Const
  17.   LineThick : Integer = 2;
  18.   DiscMode : Boolean = True;
  19.  
  20.   CLBVer : VerString = '1.70';
  21.  
  22. {$D Lines Add-In for Clysbar. (C) 1992 by clySmic Software. All Rights Resv'd.}
  23.  
  24. {-----------------------------------------------}
  25.  
  26. { --- Perform Add-In's initialization --- }
  27.  
  28. Function InitAddIn(CurVer : PChar) : InitResult; Export;
  29.  
  30. Begin
  31.   Randomize;
  32.  
  33.   { Version check }
  34.   If StrComp(CurVer,CLBVer) <> 0
  35.     Then InitAddIn := InitNotOk
  36.     Else InitAddIn := InitOk;
  37. End {InitAddIn};
  38.  
  39. {-----------------------------------------------}
  40.  
  41. { --- Paint on the button (Clysbar does the background) --- }
  42.  
  43. Procedure PaintAddIn(Wnd : HWnd; DC : HDC; Pressed : Boolean); Export;
  44.  
  45. Begin
  46. End {DrawAddIn};
  47.  
  48. {-----------------------------------------------}
  49.  
  50. { --- Tell Clysbar what kind of timer we need --- }
  51.  
  52. Function TimerNeeded : Integer; Export;
  53.  
  54. Begin
  55.   TimerNeeded := ait_Fast;
  56. End {TimerNeeded};
  57.  
  58. {-----------------------------------------------}
  59.  
  60. { --- Proc called when timer expires, perform timed duties --- }
  61.  
  62. Procedure AddInTimer(Wnd : HWnd; DC : HDC); Export;
  63.  
  64. Const
  65.   xSav : Integer = 5;
  66.   ySav : Integer = 5;
  67.  
  68. Var
  69.   Rect : TRect;
  70.   OldPen,ThePen : HPen;
  71.  
  72. Begin
  73.   { If add-in is never uncovered, Wnd will be NULL }
  74.   If wnd = 0
  75.     Then Exit;
  76.  
  77.   { Don't draw over button "edges" }
  78.   GetClientRect(Wnd,Rect);
  79.   InflateRect(Rect,-6,-6);
  80.  
  81.   { Draw a random line in a random color }
  82.   ThePen := CreatePen(ps_Solid,LineThick,RGB(Random(256),Random(256),Random(256)));
  83.   OldPen := SelectObject(DC,ThePen);
  84.  
  85.   If DiscMode 
  86.     Then Begin
  87.            { Disconnected lines }
  88.            MoveTo(Dc,Random(Rect.Right-2) + Rect.Left-2,
  89.                      Random(Rect.Bottom-2) + Rect.Top-2);
  90.            LineTo(Dc,Random(Rect.Right-2) + Rect.Left-2,
  91.                      Random(Rect.Bottom-2) + Rect.Top-2);
  92.          End
  93.     Else Begin
  94.            { Connected lines }
  95.            MoveTo(DC,xSav,ySav);
  96.            xSav := Random(Rect.Right-2) + Rect.Left-2;
  97.            ySav := Random(Rect.Bottom-2) + Rect.Top-2;
  98.            LineTo(DC,xSav,ySav);
  99.          End;
  100.  
  101.   { Clean up }
  102.   SelectObject(DC,OldPen);
  103.   DeleteObject(ThePen);
  104. End {AddInTimer};
  105.  
  106. {-----------------------------------------------}
  107.  
  108. { --- Proc called when button pressed --- }
  109.  
  110. Procedure AddInPressed(Wnd : HWnd; DC : HDC); Export;
  111.  
  112. Begin
  113.   LineThick := Random(4) + 1;    {1..4}
  114.  
  115.   DiscMode := Not DiscMode;
  116.  
  117.   PaintAddIn(Wnd,DC,False);
  118. End {AddInPressed};
  119.  
  120. {-----------------------------------------------}
  121.  
  122. { --- Exit processing for Add-In --- }
  123.  
  124. Procedure ExitAddIn; Export;
  125.  
  126. Begin
  127. End {ExitAddIn};
  128.  
  129. {-----------------------------------------------}
  130.  
  131. { --- Clysbar queries Add-In about itself (N.B.: not implemented yet) --- }
  132.  
  133. Procedure AddInAbout(Str1,Str2 : PChar;
  134.                      Var TheIcon : HIcon;
  135.                      Var TitleCol,TxCol,BkCol : TColorRef); Export;
  136.  
  137. Begin
  138.   StrCopy(Str1,'Lines V1.70');
  139.   StrCopy(Str2,'A Random Line Drawer'#13'⌐ 1992 by clySmic Software.'#13'All Rights Reserved.');
  140.  
  141.   TheIcon := LoadIcon(hInstance,'ABOUT');
  142.  
  143.   TitleCol := RGB(255,0,255);
  144.   TxCol := RGB(128,0,128);
  145.   BkCol := RGB(255,255,255);
  146. End {AddInAbout};
  147.  
  148. {-----------------------------------------------}
  149.  
  150. Exports InitAddIn    Index 1,
  151.         PaintAddIn   Index 2,
  152.         TimerNeeded  Index 3,
  153.         AddInTimer   Index 4,
  154.         AddInPressed Index 5,
  155.         ExitAddIn    Index 6,
  156.         AddInAbout   Index 7;
  157.  
  158. Begin
  159. End.
  160.