Autor Beitrag
Stread
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 188

Win 7
Delphi XE
BeitragVerfasst: Do 01.04.10 10:49 
Hi,
ich möchte dass wenn man mit der Maus über den Bildschirm fährt die Koordinaten (X|Y) wo sich der Mauszeiger gerade befindet in der Delphi Form in 2 Edit Feldern angezeigt wird.
Bis jetzt habe ich es nur geschafft die Koordinaten in der Delphi Form anzeigen zu lassen. Sobald der Mauszeiger die Form verlässt, werden keine Koordinaten mehr angezeigt.

Wie kann man das Realisieren?


Bisher hab ich es so

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm12.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
XEdit.Text:= IntToStr(X);
YEdit.Text:= IntToStr(Y)
end;
Xentar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2077
Erhaltene Danke: 2

Win XP
Delphi 5 Ent., Delphi 2007 Prof
BeitragVerfasst: Do 01.04.10 11:01 
TForm.OnMouseMove wird eben nur ausgeführt, wenn man die Maus über dem Formular bewegt.
Wenn du das allgemein haben möchtest, könntest du dies z.B. mit nem Timer tun, und dann regelmäßig GetCursorPos (oder heißt das GetMousePos..?) abfragen.

_________________
PROGRAMMER: A device for converting coffee into software.
Stread Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 188

Win 7
Delphi XE
BeitragVerfasst: Do 01.04.10 14:03 
Ich habe nun hinbekommen.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TForm12.Timer1Timer(Sender: TObject);
var
  MousePosition : TPoint;
begin
  GetCursorPos(MousePosition);
  EditX.Text:=IntToStr(MousePosition.X);
  EditY.Text:=IntToStr(MousePosition.Y);

end;


Zuletzt bearbeitet von Stread am Do 01.04.10 14:12, insgesamt 1-mal bearbeitet
JonS
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 43

XP, Vista, Seven, Ubuntu
Delphi for Win32, Delphi Prism, C#, Java, PHP, VB
BeitragVerfasst: Do 01.04.10 14:08 
In das Timer.OnTimer-Event schreiben ;)

wfg Jon S.