Autor Beitrag
christian87
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 45



BeitragVerfasst: Di 16.01.07 17:03 
Ich möchte nachdem man auf einen Button klickt, dass man die Maus nur in der Paintbox bewegen kann!
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Di 16.01.07 17:05 
ClipCursor(Paintbox1.ClientRect) sperrt den Cursor ein, und ClipCursor(Nil) lässt ihn wieder frei.

_________________
We are, we were and will not be.
christian87 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 45



BeitragVerfasst: Di 16.01.07 17:15 
Danke für die Antwort.
Eine Frage hätte ich noch. Und zwar Frage ich jetzt über einen Timer die aktuelle Mausposition ab. Jetzt möchte ich aber nicht die Mausposition meiner Form, sondern die Position in der PAintbox haben. Wie mache ich das? Wird ja nur eine kleine Umänderung sein.
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Di 16.01.07 17:17 
Über das OnMouseMove-Event erhältst du in X und Y die relative Position der Maus auf der Paintbox. Ganz ohne einen Timer. :D

_________________
We are, we were and will not be.
christian87 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 45



BeitragVerfasst: Di 16.01.07 17:19 
Danke für die schnelle Antwort. Aber zu deiner ersten Antwort. Irgendwie zeigt er mir ein Fehler an. (Inkompatible Typen Prect und TRect)
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Di 16.01.07 17:26 
Das geht auch so nicht...
Denn ClipCursor erwartet einen Pointer auf ein TRect und nicht direkt ein TRect. ;-)
Also:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
var
  tmp: TRect;
begin
  tmp := PaintBox1.ClientRect;
  ClipCursor(@tmp);

Da ClientRect eine Eigenschaft und keine Variable ist, kann man nicht direkt die Adresse von ClientRect nehmen.