Autor Beitrag
Taktaky
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 25



BeitragVerfasst: Fr 04.07.08 20:06 
Hallo

mit dieser Funktion wird die Cursor-Position ausgelesen
ich möchte aber die Position ein wenig rutschen z.B. Cursor.Position in x +30 und Cursor.Position in y +30

Wo muss ich in der Funktion (Point.x, Point.y) eingeben ?
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
// 1. Get the handle to the current mouse-cursor and its position
function GetCursorInfo2: TCursorInfo;
var
 hWindow: HWND;
 pt: TPoint;
 pIconInfo: TIconInfo;
 dwThreadID, dwCurrentThreadID: DWORD;
begin
 Result.hCursor := 0;
 ZeroMemory(@Result, SizeOf(Result));
// Find out which window owns the cursor
if GetCursorPos(pt)then
begin
   Result.ptScreenPos := pt;
   hWindow := WindowFromPoint(pt);
if IsWindow(hWindow)then
begin
// Get the thread ID for the cursor owner.
     dwThreadID := GetWindowThreadProcessId(hWindow, nil);
 
// Get the thread ID for the current thread
     dwCurrentThreadID := GetCurrentThreadId;
 
// If the cursor owner is not us then we must attach to
// the other thread in so that we can use GetCursor() to
// return the correct hCursor
if(dwCurrentThreadID <> dwThreadID)then
begin
if AttachThreadInput(dwCurrentThreadID, dwThreadID, True)then
begin
// Get the handle to the cursor
         Result.hCursor := GetCursor;
         AttachThreadInput(dwCurrentThreadID, dwThreadID, False);
end;
end
else
begin
       Result.hCursor := GetCursor;
end;
end;
end;
end;
ZeitGeist87
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1593
Erhaltene Danke: 20

Win95-Win10
Delphi 10 Seattle, Rad Studio 2007, Delphi 7 Prof., C++, WSH, Turbo Pascal, PHP, Delphi X2
BeitragVerfasst: Fr 04.07.08 20:37 
Suche in der Entwickler-Ecke SETCURSOR und Suche in der Entwickler-Ecke GETCURSOR sollten dir helfen

_________________
Wer Provokationen, Ironie, Sarkasmus oder Zynismus herauslesen kann soll sie ignorieren um den Inhalt meiner Beiträge ungetrübt erfassen zu können.
Hidden
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2242
Erhaltene Danke: 55

Win10
VS Code, Delphi 2010 Prof.
BeitragVerfasst: Fr 04.07.08 22:12 
Alternativ auch(Glaskugel an, warum du die Position verändern willst) ScreenToClient, ClientToScreen. Willst du die Position auf die einer Standard-Komponente umrechnen?

Es gibt auch Events, die die CurserPosiztion schon direkt auf die Form, etc. umrechnen.

_________________
Centaur spears can block many spells, but no one tries to block if they see that the spell is a certain shade of green. For this purpose it is useful to know some green stunning hexes. (HPMoR)
Tilman
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1405
Erhaltene Danke: 51

Win 7, Android
Turbo Delphi, Eclipse
BeitragVerfasst: Fr 04.07.08 22:22 
user profile iconTaktaky hat folgendes geschrieben:

Wo muss ich in der Funktion (Point.x, Point.y) eingeben ?
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
begin
 Result.hCursor := 0;
 ZeroMemory(@Result, SizeOf(Result));
// Find out which window owns the cursor
if GetCursorPos(pt)then
begin
   Result.ptScreenPos := pt;
   hWindow := WindowFromPoint(pt);
if IsWindow(hWindow)then


In dieser Zeile wird das Result auf den Punkt gesetzt. Du kannst also nach der Zeile mit result.ptScreenPos.x := result.ptScreenPos.x + 30;
vermutlich deinen gewünschten Effekt erzielen.


Wobei mir nicht ganz klar ist was die ganze Funktion soll. Falls du sie nur abgeschrieben hast, solltest du dir mal die Funktionen

ausblenden Delphi-Quelltext
1:
2:
getCursorPos(p: TPonint);
setCursorPos(x,y: Integer);


jeweils genauer anschauen.

_________________
Bringe einen Menschen zum grübeln, dann kannst du heimlich seinen Reis essen.
(Koreanisches Sprichwort)
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Sa 05.07.08 07:41 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
var
  P: TPoint;
begin
  P := Mouse.CursorPos;
  Inc(P.X, 30);
  Inc(P.Y, 30);
  Mouse.CursorPos := P;
end;