unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 =
class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure Button1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure Button2MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
ButtonPressed: boolean;
procedure SendSign(Zeichen: char);
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure Wait(milliseconds: Cardinal);
var
Start : Integer;
begin
Start := GetTickCount;
while GetTickCount-Start <= milliseconds
do
Application.ProcessMessages;
end;
procedure TForm1.SendSign(Zeichen: char);
begin
while ButtonPressed
do
begin
ApdComPort1.Output := Zeichen;
Wait(200);
end;
end;
procedure TForm1.Button1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
ButtonPressed := true;
end;
procedure TForm1.Button1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
ButtonPressed := false;
end;
begin
procedure TForm1.Button2Click(Sender: TObject);
begin
SendSign('
+');
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
SendSign('
+');
end;
procedure TForm1.Button2MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
ButtonPressed := true;
end;
procedure TForm1.Button2MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
ButtonPressed := false;
end;
end.