home *** CD-ROM | disk | FTP | other *** search
/ Chip: Shareware for Win 95 / Chip-Shareware-Win95.bin / ostatni / delphi / delphi1 / lmdtoolb.exe / demos / joystick / main.pas < prev   
Encoding:
Pascal/Delphi Source File  |  1995-09-08  |  2.8 KB  |  110 lines

  1. unit Main;
  2. {Demo-Program for TLMDJoystick.
  3.  
  4.  Very small app to demonstrate some features of the TLMDJoystick
  5.  component. If you move the Joystick"cursor" to a label, press the
  6.  button and the label will be removed...
  7.  In the CaptionBar the Manufactorere of the Joystickdriver will be
  8.  displayed. If not, the current selected Joystick isn't
  9.  available.
  10.  
  11.  This program is freeware. Use it and enjoy!
  12.  If you made any improvements it would be nice to send them to me.
  13.  
  14.  ⌐ 1995 by LMD Innovative
  15.  
  16.  ------------------------------------------------------------------
  17.  History:
  18.  0.01.00 (06.09.95): First Version
  19.  
  20.  Author: RM}
  21.  
  22. interface
  23.  
  24. uses
  25.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  26.   Forms, Dialogs, Joystick, ExtCtrls, StdCtrls, mmSystem, Lmdjoyst, Lmdhint;
  27.  
  28. type
  29.   TForm1 = class(TForm)
  30.     LMDJoystick1: TLMDJoystick;
  31.     Label1: TLabel;
  32.     Label2: TLabel;
  33.     Label3: TLabel;
  34.     Label4: TLabel;
  35.     Label5: TLabel;
  36.     Label6: TLabel;
  37.     Label7: TLabel;
  38.     Label8: TLabel;
  39.     ziel: TShape;
  40.     procedure LMDJoystick1JoyStickMove(Sender: TObject;
  41.       Buttons: TJoystickButtons; X, Y: Word);
  42.     procedure LMDJoystick1JoyButtonDown(Sender: TObject;
  43.       Buttons: TJoystickButtons; X, Y: Word);
  44.     procedure LMDJoystick1JoyButtonUp(Sender: TObject;
  45.       Buttons: TJoystickButtons; X, Y: Word);
  46.     procedure FormCreate(Sender: TObject);
  47.   private
  48.     { Private-Deklarationen }
  49.   public
  50.     { Public-Deklarationen }
  51.   end;
  52.  
  53. var
  54.   Form1: TForm1;
  55.   actpos:TPoint;
  56. implementation
  57.  
  58. {$R *.DFM}
  59.  
  60. procedure TForm1.LMDJoystick1JoyStickMove(Sender: TObject;
  61.   Buttons: TJoystickButtons; X, Y: Word);
  62. begin
  63.     actpos.x:=round((x/65535)*(ClientWidth));
  64.     actpos.y:=round((y/65535)*(ClientHeight));
  65.     ziel.left:=actpos.x-5;
  66.     ziel.top:=actpos.y-5;
  67. end;
  68.  
  69. procedure TForm1.LMDJoystick1JoyButtonDown(Sender: TObject;
  70.   Buttons: TJoystickButtons; X, Y: Word);
  71. var i:integer;
  72.  
  73. begin
  74.  
  75.    ziel.brush.color:=clred;
  76.     for i:=0 to ComponentCount -1 do
  77.      if Components[i] is TLabel then
  78.       if PtInRect((Components[i] as TLabel).Boundsrect,actpos) then
  79.         begin
  80.           {here should be a nice explosion...}
  81.           TLabel(Components[i]).Visible:=false;
  82.           break;
  83.         end;
  84.  
  85. end;
  86.  
  87. procedure TForm1.LMDJoystick1JoyButtonUp(Sender: TObject;
  88.   Buttons: TJoystickButtons; X, Y: Word);
  89. begin
  90.   ziel.brush.style:=bsclear;
  91. end;
  92.  
  93. procedure TForm1.FormCreate(Sender: TObject);
  94. begin
  95.  
  96.   {the manufactorer wof the actual driver will be displayed in the
  97.    Captionbar of the Window}
  98.  
  99.   with lmdjoystick1 do
  100.     if testavailable(JoystickID) then
  101.       begin
  102.        LMDJoystick1.enabled:=true;
  103.        caption:=Caption + ' '+StrPas(LMDJoyStick1.GetJoystickCaps.szPName);
  104.       end
  105.     else
  106.       caption:=Caption + ' No joystick available...'
  107. end;
  108.  
  109. end.
  110.