AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Sprachen und Entwicklungsumgebungen Sonstige Fragen zu Delphi Delphi Mouseposition innerhalb des Forms bestimmen
Thema durchsuchen
Ansicht
Themen-Optionen

Mouseposition innerhalb des Forms bestimmen

Offene Frage von "skyquaker"
Ein Thema von skyquaker · begonnen am 8. Feb 2007 · letzter Beitrag vom 10. Feb 2007
Antwort Antwort
skyquaker

Registriert seit: 14. Sep 2006
96 Beiträge
 
Delphi 7 Professional
 
#1

Re: Mouseposition innerhalb des Forms bestimmen

  Alt 8. Feb 2007, 18:19
Zitat von bitsetter:
Wenn du das Handle des fremden Fensters kennst, müsste folgendes funktionieren.
Delphi-Quellcode:
function GetPos(Handle: HWND): TPoint;
var
   WinInfo: TWindowInfo;
   CurPos: TPoint;
begin
   Result.X:= -1;
   Result.Y:= -1;
   FillChar(WinInfo, Sizeof(WinInfo), 0);
   WinInfo.cbSize := Sizeof(WinInfo);
   GetWindowInfo(Handle, WinInfo);
   GetCursorPos(CurPos);
   //if windows.PtInRect(WinInfo.rcWindow, CurPos) then
   if windows.PtInRect(WinInfo.rcClient, CurPos) then
     begin
       Result.X:= CurPos.X- WinInfo.rcClient.Left;
       Result.Y:= CurPos.Y- WinInfo.rcClient.Top;
     end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  CurPos: TPoint;
begin
  CurPos:= GetPos(Form1.Handle);
  Caption:= 'X: '+inttostr(CurPos.X)+ ' Y: '+inttostr(CurPos.Y);
end;

procedure SetPos(Handle: HWND; CurPos: TPoint);
var
   WinInfo: TWindowInfo;
begin
   FillChar(WinInfo, Sizeof(WinInfo), 0);
   WinInfo.cbSize := Sizeof(WinInfo);
   GetWindowInfo(Handle, WinInfo);
   inc(CurPos.X, WinInfo.rcClient.Left);//WinInfo.rcWindow.Left
   inc(CurPos.Y, WinInfo.rcClient.Top);//WinInfo.rcWindow.Top
   if windows.PtInRect(WinInfo.rcClient, CurPos) then
   setCursorPos(CurPos.X, CurPos.Y);
end;

procedure TForm1.Button2Click(Sender: TObject);
var
  CurPos: TPoint;
begin
  CurPos.X:= 5;
  CurPos.Y:= 15;
  SetPos(Form1.Handle, CurPos);
end;
Ich hoffe mal, du meintest es auch so.
Ja, das sieht stark nach dem aus, was ich suche. Kann mir jemand sagen, wie ich das Hangle des Fensters auslese?
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 08:40 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz