unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TDemoForm =
class(TForm)
cbxMouseIsDown: TCheckBox;
procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure FormMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure FormKeyPress(Sender: TObject;
var Key: Char);
private
MouseIsDown: boolean;
end;
var
DemoForm: TDemoForm;
implementation
{$R *.dfm}
procedure TDemoForm.FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
MouseIsDown := true;
// actions
end;
procedure TDemoForm.FormMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if MouseIsDown
then begin
// actions
MouseIsDown := false;
end;
end;
procedure TDemoForm.FormKeyPress(Sender: TObject;
var Key: Char);
begin
if MouseIsDown
then
if Key = Chr(VK_ESCAPE)
then begin
MouseIsDown := false;
Key := #0
end;
end;
end.