We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Capturing a MouseDown and Mouse Released with a out of focus form

groone
groone asked
on
Medium Priority
406 Views
Last Modified: 2008-03-10
I have a form with a text box in it.  Say for instance Notepad.exe is in focus and my form is behind it.  Everytime the mouse button is pushed in notepad, I would for the form behind it to display a message "Mouse Button Down" as an example, then when the mouse button is released in Notepad I would want the non focused form to display "Mouse Button Released"
Comment
Watch Question

Commented:
Use the private Sub  Form_mousedown & form_mouseup.....

BTW you tend to get better answers if you offer more than 10 points... (the average Q goes for around a 100 ... 50 for easy)

Commented:
As far as I know, you can't.
You should install a MouseHook, and I think it's not possible in VB. You can only retrieve mouse events on your App's forms.
A Hook is a often system defined message queue, you can build a messagehook that traps all messages before going to other windows, but as I said befor, I think you must use lenguajes such as C++

Commented:
What you're talking about is cross-task subclassing and is not for the faint of heart.

If you're interested, Dan Appleman has some examples of cross-task subclassing in VB (actually adding menu items, etc. to Notepad) using SpyWorks VB.

You can get more information from www.desaware.com.

Good luck.

Author

Commented:
Because Maverick said to raise the stakes ;p  and I added a question so now I expect some work ;p
This is VB 5
The form must be out of focus for it to capture the mouse down and mouse up event.  Is there anything that does the same function as GetKeyState, GetKeyboardState, and GetAsyncKeyboard for the mouse?  I checked DA's win32 api book and couldnt find anything.  

Added question, how do I clear system keyboard buffers?

Commented:
>now I expect some work
I think good pointer (or link) is better then a work.
kswinney told you the right answer.
I also know one link: to free C-dll that catches the keys.

Commented:
Raise the stakes.....:)  I disagree with ameba that a link is better than work.... If you put 350 on a question you can expect a fair bit of work......
Another option is to carefully look through the PAQs for ideas ... I think its there somewhere


Commented:
Hi, MAVERICK
>I disagree with ameba that a link is better than work

The idea is not: do the work for somebody, but to HELP.

Example (my first answer on EE)
Q: Make the 1st col of ListView a TreeView?
I answered with code to SET_INDENT, exactly what was asked.
I remember I got the code somewhere on the NET. It also contains code to GET_INDENT.
With a little more effort, instead of pasting my code, isn't it better to find and give the "original" source link with example and "full source"? It is also fair to give credits to original authors.

Author

Commented:
Well, the link that was provided to me was a link to purchase a book that I already own.  The book is fantastic, but it does not have or I cannot find what I need in it concerning my question.  The link that was given was worthless to me...sorry kswinney.  And MAVERICK, if I raise it some more...you better be the one answerring ;p


Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Commented:
Clever solution without a hook. Great! Congratulations, covington!

Author

Commented:
Hey, this was a darn good snippet of code.  Excellent!  As you can see I raised the point value.

I will definately be able to work with this code.

Again thanks, and sorry it took so long for me to get back to you.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.