Autor Beitrag
Krefti
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 164

Win XP/Vista/Win7/ubuntu
Delphi 7/2006/2009 Pro
BeitragVerfasst: Do 09.11.06 14:36 
hi zusammen,

ich habe die Cursorpostion auf meinem Image1 mit hilfe der onmousemove ermittelt und auf zwei labels ausgegeben.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
var
     mausx,
     mausy : integer;
begin

    mausx:=Mouse.CursorPos.x;
    mausy:=Mouse.CursorPos.y;
    label5.Caption:='X = ' + FloatToStr(mausx);
    label6.Caption:='Y = ' + FloatToStr(mausy);
end;


so werden mir die pixels im bezug auf den ganzen bildschirm ausgegeben. Wie kann ich es machen, dass sie im Verhältniss zu meinem Image, also dass die obere linke ecke(und nicht die bildschirmecke) im Image1 0,0 ist???

Vielen dank schon mal für eure hilfe!!

gruß


Moderiert von user profile iconGausi: Topic aus Multimedia / Grafik verschoben am Do 09.11.2006 um 15:01
Benedikt
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Do 09.11.06 14:58 
Hi,

ScreenToClient ist das, was du suchst :wink:

ausblenden Delphi-Quelltext
1:
2:
    mausx:=Image1.ScreenToClient(Mouse.CursorPos).x;
    mausy:=Image1.ScreenToClient(Mouse.CursorPos).y;
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: Do 09.11.06 15:01 
Wald, Bäume... :roll:

Warum nimmst du nicht die X/Y-Werte, die dir das OnMouseMove-Event liefert? Schau mal in den Kopf der Prozedur!

_________________
We are, we were and will not be.
Benedikt
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Do 09.11.06 18:08 
Ups, das ist mir beim Schreiben meiner Methode gar nicht eingefallen, die zwar auch funktioniert - hier aber wirklich unsinnig ist :wink:
Krefti Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 164

Win XP/Vista/Win7/ubuntu
Delphi 7/2006/2009 Pro
BeitragVerfasst: Fr 10.11.06 08:05 
vielen dank!!