Link to home
Start Free TrialLog in
Avatar of fcp
fcp

asked on

How to implement a "MouseOver" function?

I need to know when the mouse move from inside a picbox (whn i use the mousemove event) to outside.
The porblems are that
1) no buttons are pressed, so the picbox don't "capture" mouse moves outside itself
2) I've too many controls around that picbox to write a mousemove event in each to know that the mouse in now outside the picbox, and the form space between all controls are to little to be sure that form detect a mousemove.

So i think i need some API stuffs.. please write some pseudo working code... thanks
Avatar of Sethi
Sethi
Flag of India image

You will have to write the code in MouseMove event of the form also. This is becuase as soon as the mouse moves outside picturebox the mouseevent of the form gets fired. In case there is some other control attached with the picturebox and the form is not visible then write code in Mousemove event of that control.
To shorten the coding effort declare a sub and write the effective code in that sub. Then simply call that sub in MouseMove event of all the controls.
ASKER CERTIFIED SOLUTION
Avatar of jgv
jgv

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of CuBr
CuBr

Nice code, jgv.  Too bad it doesn't work with Images though.

Here is an article (and source code) that may help you:

"Generating MouseLeave Events for a Window"
http://www.vbaccelerator.com/home/VB/Code/Libraries/Subclassing/Generating_MouseLeave_Events_for_a_Window/article.asp

HTH
M
Hello fcp,

try doing this.
1.Take a global varibale as boolean.
2.Set default value to false.
3.Whenever mousemoves on the PictureBox, make the variable value to True.
Write the condition as:
if <GlobalVariable> = false then
<GlobalVariable> = true
end if
4.Thus you will get the exact point when the mouse moves over the PictureBox.
5.In the Form_Maousemove, set the variable to false only if it is already true.
Write the condition as:
if <GlobalVariable> = true then
<GlobalVariable> = false
end if
6.Do the same thing in Other Controls' MouseMove.
7.Choose only those controls which are very close to the PictureBox, so that you will not have to write the code,in each and every control's MouseMove event.
8.Doing this, your logic with the other program will remain inract.
9. But I think capturing,both these events should solve your problem.
10.As we have taken a variable, on basic of this you can also code, if required.

All The Best.
Avatar of fcp

ASKER

WOW! Very fast. THANKS