Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi Maus-Hook: Mausrad-Richtung (https://www.delphipraxis.net/144697-maus-hook-mausrad-richtung.html)

LinuxFan 14. Dez 2009 22:16


Maus-Hook: Mausrad-Richtung
 
Hallo!

Mein MausHook:
Delphi-Quellcode:
function MouseHookProc(nCode: Integer; MsgID: WParam; Data: LParam): LResult; stdcall;
begin
...
PostMessage(mainWnd, MouseHookMessage, MsgID, Data);
...
end;
Mein Hauptprogramm:

Delphi-Quellcode:
procedure TMainHookTestForm.WndProc(var Message: TMessage);
begin
...
MouseSignal(message.WParam, message.LParam);
end;

procedure TMainHookTestForm.MouseSignal(msgId: Integer; Data: Integer);
begin
...
logText := logText + 'mouse X: ' + IntToStr(mousePos.X) + ' Y: ' + IntToStr(mousePos.Y) + '/state=' + IntToStr(msgId) + '/data=' + IntToStr(Data) + #13#10;
...
end;
Wenn ich die Nachricht (msgID) "WM_MOUSEWHEEL" empfange,
steht in der Variable Data nichts verwertbares über das Mausrad-Delta drin.

Woher kann ich denn die Information bekommen, in welche Richtung das Mausrad gedreht wurde?

Mithrandir 15. Dez 2009 04:43

Re: Maus-Hook: Mausrad-Richtung
 
Delphi-Referenz durchsuchenWM_MOUSEWHEEL

Aus der MSDN:

Zitat:

The high-order word indicates the distance the wheel is rotated, expressed in multiples or divisions of WHEEL_DELTA, which is 120. A positive value indicates that the wheel was rotated forward, away from the user; a negative value indicates that the wheel was rotated backward, toward the user.

The low-order word indicates whether various virtual keys are down. This parameter can be one or more of the following values.
Delphi-Quellcode:
end;

procedure TMainHookTestForm.MouseSignal(msgId: Word; Data: Word); //Word oder DWord, bin mir grad nicht sicher...
begin
...
logText := logText + 'mouse X: ' + IntToStr(mousePos.X) + ' Y: ' + IntToStr(mousePos.Y) + '/state=' + IntToStr(High(msgId)) + '/data=' + IntToStr(Data)) + #13#10;
...
end;
Sollte eigentlich das gewünschte Ergebnis bringen... Ansonsten steht alles Relevant in dem MSDN-Eintrag...

himitsu 15. Dez 2009 06:49

Re: Maus-Hook: Mausrad-Richtung
 
Wo kommt denn die Definition von MouseSignal her?

http://msdn.microsoft.com/en-us/libr...8VS.85%29.aspx
Alles DWORD, aber in Delphi würde ich den Delphieigenen Dypen LongWord nehmen.

Zitat:

The high-order word indicates the distance the wheel is rotated, expressed in multiples or divisions of WHEEL_DELTA, which is 120.
Delphi-Quellcode:
Distance := ShortInt(WParam shr 16)

LinuxFan 15. Dez 2009 09:18

Re: Maus-Hook: Mausrad-Richtung
 
Hi,

MouseSignal ist eine Prozedur von mir, die die erhaltenene Nachricht (kommt per WndProc rein) verarbeitet.

Danke für die Tipps, ich schaus mir mal an.


Alle Zeitangaben in WEZ +1. Es ist jetzt 21:54 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