Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
72
Task/Joystick-position/Delphi/joystick-position-1.delphi
Normal file
72
Task/Joystick-position/Delphi/joystick-position-1.delphi
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
unit uMain;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Winapi.Windows, System.SysUtils, System.Classes, Vcl.Controls, Vcl.Forms,
|
||||
Vcl.ExtCtrls, Vcl.StdCtrls;
|
||||
|
||||
type
|
||||
TForm1 = class(TForm)
|
||||
tmr1: TTimer;
|
||||
lblPosition: TLabel;
|
||||
procedure tmr1Timer(Sender: TObject);
|
||||
procedure FormPaint(Sender: TObject);
|
||||
private
|
||||
{ Private declarations }
|
||||
public
|
||||
{ Public declarations }
|
||||
procedure DrawCrosshair(X, Y: Integer);
|
||||
end;
|
||||
|
||||
var
|
||||
Form1: TForm1;
|
||||
X: Integer = 0;
|
||||
Y: Integer = 0;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
mmSystem, Vcl.Graphics;
|
||||
|
||||
{$R *.dfm}
|
||||
|
||||
procedure TForm1.DrawCrosshair(X, Y: Integer);
|
||||
const
|
||||
RADIUS = 10;
|
||||
CROSS = 3;
|
||||
begin
|
||||
Canvas.Brush.Color := clblack;
|
||||
Canvas.FillRect(ClientRect);
|
||||
with Canvas do
|
||||
begin
|
||||
Pen.Color := clWhite;
|
||||
pen.Width := 1;
|
||||
Ellipse(X - RADIUS, Y - RADIUS, X + RADIUS, Y + RADIUS);
|
||||
pen.Width := 2;
|
||||
MoveTo(X - CROSS * RADIUS, Y);
|
||||
LineTo(X + CROSS * RADIUS, Y);
|
||||
MoveTo(X, Y - CROSS * RADIUS);
|
||||
LineTo(X, Y + CROSS * RADIUS);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TForm1.FormPaint(Sender: TObject);
|
||||
begin
|
||||
DrawCrosshair(X, Y);
|
||||
end;
|
||||
|
||||
procedure TForm1.tmr1Timer(Sender: TObject);
|
||||
var
|
||||
info: TJoyInfo;
|
||||
begin
|
||||
if (joyGetPos(0, @info) = 0) then
|
||||
begin
|
||||
X := Round(ClientWidth * info.wXpos / MAXWORD);
|
||||
Y := Round(ClientHeight * info.wYpos / MAXWORD);
|
||||
lblPosition.Caption := Format('(%3d,%3d)', [X, Y]);
|
||||
Invalidate;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
36
Task/Joystick-position/Delphi/joystick-position-2.delphi
Normal file
36
Task/Joystick-position/Delphi/joystick-position-2.delphi
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
object Form1: TForm1
|
||||
Left = 0
|
||||
Top = 0
|
||||
Caption = 'Form1'
|
||||
ClientHeight = 600
|
||||
ClientWidth = 600
|
||||
Color = clBtnFace
|
||||
Font.Charset = DEFAULT_CHARSET
|
||||
Font.Color = clWindowText
|
||||
Font.Height = -11
|
||||
Font.Name = 'Tahoma'
|
||||
Font.Style = []
|
||||
OldCreateOrder = False
|
||||
OnPaint = FormPaint
|
||||
PixelsPerInch = 96
|
||||
TextHeight = 13
|
||||
object lblPosition: TLabel
|
||||
Left = 500
|
||||
Top = 0
|
||||
Width = 100
|
||||
Height = 21
|
||||
Alignment = taCenter
|
||||
AutoSize = False
|
||||
Caption = '(0,0)'
|
||||
Font.Charset = DEFAULT_CHARSET
|
||||
Font.Color = clWhite
|
||||
Font.Height = -20
|
||||
Font.Name = 'Tahoma'
|
||||
Font.Style = []
|
||||
ParentFont = False
|
||||
end
|
||||
object tmr1: TTimer
|
||||
Interval = 500
|
||||
OnTimer = tmr1Timer
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue