[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Mouse hovering

Posted on 2000-05-14
10
Medium Priority
?
235 Views
Last Modified: 2010-04-04
How to detect the handle of a window that the mouse is hovering over?
0
Comment
Question by:duke_n
[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
  • 3
  • 3
  • 2
  • +2
10 Comments
 
LVL 17

Expert Comment

by:inthe
ID: 2809658
hi,
to get the handle and classname of control/window under mouse you can use :

var
classname: array[0..254] of char;
h : hwnd;
begin
h := WindowFromPoint(TControl(Sender).ClientToScreen(Point(X, Y)));
GetClassName(h, classname, 254);

Regards Barry

0
 
LVL 1

Author Comment

by:duke_n
ID: 2811156
That's nice.

But I need it to give me the window handle even If I'm pointing on a button in that window.
0
 
LVL 17

Expert Comment

by:inthe
ID: 2811746
well you could put something like this on a timer(set to 100)

procedure TForm1.Timer1Timer(Sender: TObject);
var
mp,i1,i2: integer;
p: tpoint;
h : hwnd;
begin
 mp:=getmessagepos();
  i1:=hiword(mp);
  i2:=loword(mp);
    p.y:=i1;
    p.x:=i2;
   h:=windowfrompoint(p);
  edit1.text :=
'mouse is over handle ' +inttostr(h);
end;
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 5

Expert Comment

by:Gwena
ID: 2811831
listening
0
 
LVL 5

Expert Comment

by:Gwena
ID: 2811835
listening
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 2813339
hi all,

what about

var
  P : TPoint;
  H : THandle;
begin
  GetCursorpos(P);      //Get MousePos
  H := WindowFromPoint(P); //Get WindowHandle
end;

meikl
0
 
LVL 1

Author Comment

by:duke_n
ID: 2813993
Barry, your [second] solution is kinda strange.
It detects mouse position change from control to control on my app window, yet doesn't always detect mouse pos change from WINDOW to WINDOW.

And Meikl, your solution looks a whole lot like barry's first one. And I repeat what I didn't like there: it detects mouse pos change from control to control(windowed controls in the same "big" window).
0
 
LVL 20

Accepted Solution

by:
Madshi earned 400 total points
ID: 2814018
H := WindowFromPoint(P);
while GetParent(H) <> 0 do
  H := GetParent(H);

Regards, Madshi.
0
 
LVL 17

Expert Comment

by:inthe
ID: 2814978
oh i misunderstood duke_n's comment.
you want no matter what control the cursor is over it tells you the window handle.
{i thought you wanted to know the handle of whatever control the cursor was over..}
my mistake.
madshis last commment should sort it out .
cheers Barry
0
 
LVL 1

Author Comment

by:duke_n
ID: 2817506
Okey-Dokey.
Thanx.
0

Featured Post

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

649 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