home *** CD-ROM | disk | FTP | other *** search
- unit Main;
- {Demo-Program for TLMDJoystick.
-
- Very small app to demonstrate some features of the TLMDJoystick
- component. If you move the Joystick"cursor" to a label, press the
- button and the label will be removed...
- In the CaptionBar the Manufactorere of the Joystickdriver will be
- displayed. If not, the current selected Joystick isn't
- available.
-
- This program is freeware. Use it and enjoy!
- If you made any improvements it would be nice to send them to me.
-
- ⌐ 1995 by LMD Innovative
-
- ------------------------------------------------------------------
- History:
- 0.01.00 (06.09.95): First Version
-
- Author: RM}
-
- interface
-
- uses
- SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
- Forms, Dialogs, Joystick, ExtCtrls, StdCtrls, mmSystem, Lmdjoyst, Lmdhint;
-
- type
- TForm1 = class(TForm)
- LMDJoystick1: TLMDJoystick;
- Label1: TLabel;
- Label2: TLabel;
- Label3: TLabel;
- Label4: TLabel;
- Label5: TLabel;
- Label6: TLabel;
- Label7: TLabel;
- Label8: TLabel;
- ziel: TShape;
- procedure LMDJoystick1JoyStickMove(Sender: TObject;
- Buttons: TJoystickButtons; X, Y: Word);
- procedure LMDJoystick1JoyButtonDown(Sender: TObject;
- Buttons: TJoystickButtons; X, Y: Word);
- procedure LMDJoystick1JoyButtonUp(Sender: TObject;
- Buttons: TJoystickButtons; X, Y: Word);
- procedure FormCreate(Sender: TObject);
- private
- { Private-Deklarationen }
- public
- { Public-Deklarationen }
- end;
-
- var
- Form1: TForm1;
- actpos:TPoint;
- implementation
-
- {$R *.DFM}
-
- procedure TForm1.LMDJoystick1JoyStickMove(Sender: TObject;
- Buttons: TJoystickButtons; X, Y: Word);
- begin
- actpos.x:=round((x/65535)*(ClientWidth));
- actpos.y:=round((y/65535)*(ClientHeight));
- ziel.left:=actpos.x-5;
- ziel.top:=actpos.y-5;
- end;
-
- procedure TForm1.LMDJoystick1JoyButtonDown(Sender: TObject;
- Buttons: TJoystickButtons; X, Y: Word);
- var i:integer;
-
- begin
-
- ziel.brush.color:=clred;
- for i:=0 to ComponentCount -1 do
- if Components[i] is TLabel then
- if PtInRect((Components[i] as TLabel).Boundsrect,actpos) then
- begin
- {here should be a nice explosion...}
- TLabel(Components[i]).Visible:=false;
- break;
- end;
-
- end;
-
- procedure TForm1.LMDJoystick1JoyButtonUp(Sender: TObject;
- Buttons: TJoystickButtons; X, Y: Word);
- begin
- ziel.brush.style:=bsclear;
- end;
-
- procedure TForm1.FormCreate(Sender: TObject);
- begin
-
- {the manufactorer wof the actual driver will be displayed in the
- Captionbar of the Window}
-
- with lmdjoystick1 do
- if testavailable(JoystickID) then
- begin
- LMDJoystick1.enabled:=true;
- caption:=Caption + ' '+StrPas(LMDJoyStick1.GetJoystickCaps.szPName);
- end
- else
- caption:=Caption + ' No joystick available...'
- end;
-
- end.
-