?
Solved

Getting Mouse Coordinates

Posted on 2003-03-20
5
Medium Priority
?
163 Views
Last Modified: 2010-04-04
Hi,

I need a way of detecting the mouse position globally - regardless of what is under the mouse.  At present, I use this code:

function MouseProc(nCode: Integer; wParam: Longint; var MouseHookStruct:
  TMouseHookStruct): Longint; stdcall;
begin
  Result := CallNextHookEx(MouseHook, nCode, wParam, Longint(@MouseHookStruct));
  {
   code
  }
end;

procedure TMainForm.FormShow(Sender: TObject);
begin
  MouseHook := SetWindowsHookEx(WH_Mouse, @MouseProc, 0, GetCurrentThreadId);
end;

It works fine, except for if I drop a TMediaPlayer on the form and link it too a panel.  When the mouse cursor moves over the area that is playing the video, I no longer recieve mouse events.

Can anyone tell me how I can get this working?

Many thanks,

Stuart.
0
Comment
Question by:Stuart_Johnson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 400 total points
ID: 8177152
getcursorpos(TPointVarHere);

meikl ;-)
0
 

Expert Comment

by:rayek007
ID: 8187918
var a,b:integer;
...
a:=mouse.CursorPos.X;
b:=mouse.CursorPos.Y;
.....


Hope it helps!
0
 
LVL 6

Author Comment

by:Stuart_Johnson
ID: 8188781
Dammit!  You know, I've known about the Mouse object - I've used it so many times.  But for some reason, I used the mouse hook (it was suggested by someone else in another Experts Exchange question I asked) because in the past, the mouse object wasn't good enough for what I was doing.

Thanks :)

Stu
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 8189275
>You know, I've known about the Mouse object
do you graded the right one, stu?
0
 
LVL 6

Author Comment

by:Stuart_Johnson
ID: 8189377
Yep.  I used your code, Meikl.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month13 days, 4 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question