Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

mouse

Posted on 1999-08-02
14
Medium Priority
?
169 Views
Last Modified: 2010-06-08
How can I detect that my mouse is over a text box from another program?
0
Comment
Question by:alexbeaty
[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
  • 5
  • 3
  • 2
  • +4
14 Comments
 
LVL 1

Expert Comment

by:phiro
ID: 1529070
Use the OLEDragOver event of the textbox
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1529071
it would be difficult... for example in Delphi the class name of an edit box is originally TEdit.. and that's the best way for checking for editboxes... it is difficult..

..-=ViKtOr=-..
0
 

Author Comment

by:alexbeaty
ID: 1529072
phiro, you said I could use the OLE dragover of the text box... but it only works if it is in my program not in an outside program!
0
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!

 
LVL 1

Expert Comment

by:ajmendes
ID: 1529073
Hi,
you can see if the mouse pointer is over your app current form. then you can affect a bool flag each time the mouse pointer is not over that form.

Hope it helps
Bye
0
 
LVL 1

Expert Comment

by:Neal Hartman
ID: 1529074
Your going to need a windows hook control like Spyworks.
0
 

Author Comment

by:alexbeaty
ID: 1529075
can you give me a source example?

thx
0
 
LVL 1

Accepted Solution

by:
Maquiavelo earned 200 total points
ID: 1529076
 Use the GetFocus API function, it returns a handle of the window (the textboxes are windows too) that has the focus.

This sample line code shows U how to use the function:

Private Declare Function GetFocus Lib "user32" () As Long

lblFocus = "Focus Window: " & Str$(GetFocus())

  Then with this handle U can find out to which process it is associated, get the app name, etc.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1529077
hehehe... Mouse Over <> Focused Control
now the mouse is over the submit button but this edit window has got the focus because i'm typing in it :))

here is how to get the handle of control underneath the mouse...

type point
  x as long
  y as long
end type
....
dim h as long
dim pt as point

call GetCursorPos(pt)
h = WindowFromPoint(pt)

now "h" is a handle to the control underneath the mouse.. one way to check if it is an edit is to use this...

dim str as string * MAX_PATH-1

call GetClassName(h, str, MAX_PATH)
if UCase(str) = "EDIT" then MsgBox "The control underneath the mouse is an edit box control"

the classname is very important and most of the VC created programs would have that class name as identifier... but in Delphi for example that names is TEdit so this method would not work.. I've not tried in VB to see what the name is... some people create their own classes and change the name to whatever they want so it would be kind of difficult.. maybe there is some other identifier by which you'll be able to find that and I probably don't know of it, or can't think of it right now, but i doubt that...

..-=ViKtOr=-..
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1529078
btw, GetClassName(), GetCursorPos() and WindowFromPoint() are Win API functions so  you would have to declare them first before using them. Also, you will have to declare MAX_PATH which is a constant value. Use your API Viewer to find out what the declarations for the functions are and the constant value of MAX_PATH.

Good Luck!

..-=ViKtOr=-..
0
 
LVL 1

Expert Comment

by:Maquiavelo
ID: 1529079
 To ViKtOrnet: why using two API functions if U can do it with one? :))
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1529080
Maquiavelo, and what is the function you're talking about?
0
 
LVL 1

Expert Comment

by:Maquiavelo
ID: 1529081
Viktornet: it's in the answer. U can use GetFocus (It returns the handle of the window that has the focus at that moment) or GetCapture (the handle of the window that has the capture of the mouse).

Mq.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1529082
Maquiavelo, please read my previous comment dated Tuesday, August 03 1999 - 08:26PM PDT...

the focused control is not the same as the control under the mouse...(in most cases).. if i put the mouse over the focused control then that would be true, otherwise it isn't, so GetFocus() does not work in this case... I already told you how to get the handle of the control under the mouse...

..-=ViKtOr=-..
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6872168
GREETINGS!

This question was awarded, but never cleared due to the JSP-500 errors of that time.  It was "stuck" against userID -1 versus the intended expert whom you awarded.  This corrects the problem and the expert will now receive these points; points verified.

Please click on your Member Profile and select "View Question History" to navigate through any open or locked questions you may have to update and finalize them.  If you are an EE Pro user, you can also choose Power Search to find all your open questions.

This is the Community Support link, if help is needed, along with the link to All Topics which reflects many TAs recently added.

http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
http://www.experts-exchange.com/jsp/zonesAll.jsp
 
Thank you,
Moondancer
Moderator @ Experts Exchange
0

Featured Post

Industry Leaders: 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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

715 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