Registriert seit: 17. Jan 2007
1.169 Beiträge
Turbo Delphi für Win32
|
Re: Mauskoordinaten wie in OnMouseMove() in OnClick()
6. Jul 2007, 09:14
Hi,
Delphi-Quellcode:
type
TClickEvent = procedure (Sender: TObject; X, Y: Integer) of object;
TMyImage = class (TImage)
private
FOnClickEvent: TClickEvent;
protected
procedure Click; override;
published
property OnClick: TClickEvent read FOnClickEvent write FOnClickEvent;
end;
type
TForm1 = class(TForm)
procedure FormShow(Sender: TObject);
private
procedure NewClick(Sender: TObject; X, Y: Integer);
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TMyImage.Click;
var
MPos: TPoint;
begin
inherited;
if assigned(FOnClickEvent) then
begin
MPos:= ScreenToClient(Mouse.CursorPos);
FOnClickEvent(Self, MPos.X, MPos.Y);
end;
end;
procedure TForm1.NewClick(Sender: TObject; X, Y: Integer);
begin
Caption:= inttostr(X) + ' '+ inttostr(Y);
end;
procedure TForm1.FormShow(Sender: TObject);
var
MyI: TMyImage;
begin
MyI:= TMyImage.Create(self);
MyI.Parent:= self;
MyI.OnClick:= NewClick;
end;
Gruß bitsetter
"Viele Wege führen nach Rom" Wolfgang Mocker (geb. 1954), dt. Satiriker und Aphoristiker
|
|
Zitat
|