Mouse move event of label control (vb6)

I manage a label control mouse move event to change the forecolor of the control when the mouse move over the control. But there is a problem that on mouse move event this subroutine changes the forecolor but when the mouse move from the label control to another it does not changes the forecolor which was before the mouse move event was triggered.
pls help me for the same.
sub like this
     private sub lblExam_mousemove(.......)
         end sub
and how can i change the forecolor of the control through this sub .
pls help me
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You're going to have to change all the labels in every _mouseover event, setting the current one (the label that the mouse is over) to the color you want, and the rest to the original. In these examples, I'm using vbgray as the "original" color.

         private sub lblExam1_mousemove(.......)
         end sub
         private sub lblExam2_mousemove(.......)
         end sub
         private sub lblExam3_mousemove(.......)
         end sub

You probably want to add the defaults to your Form_MouseMove() too. This will deselect any label you just had your mouse over:

         private sub Form_mousemove(.......)
         end sub

Hope that helps.
I suggest you to do like this:

private sub Label1_mousemove(.......)
    If X < 20 Or X > Label1.Width - 20 Or Y < 20 Or Y > Label1.Height - 20 Then
    Label1.ForeColor = vbGreen
    Label1.ForeColor = vbWhite
End If

end sub

try this..................
OWASP: Threats Fundamentals

Learn the top ten threats that are present in modern web-application development and how to protect your business from them.

i saw this code...but why u use api when it can easily be done...

anyway it is upto ALIHAIDER1 to decide....
ALIHAIDER1Author Commented:
Dear expert pg_india
        Ur code is not perfect working. The color of the control is not changed event the mouse move from the control to another. The color remain vbgreen. Pls provide some perfection to aviod using api. will wait for ur response.
ALIHAIDER1Author Commented:
Dear expert
pls respond upon my qeury. Kindly do needful because i here is  something remains penging here.
Hello Ali.

Did my try my example up above?

- Paul
The color of the control is not changed event the mouse move from the control to another????

The color chages whenever the mouse moves out of a control....i don't thk there is any problem with that...
ALIHAIDER1Author Commented:
Ok will try again.
ALIHAIDER1Author Commented:
Dear expert Paul
           Your code is working good. But that 's not what i want. Actuly i want to manage this from one subroutine (mouse move).
Thanks for concern
You have a special requirement, and simple programming won't do it.  Why not just use APIs?  

Anyways, check the code below on subclassing - but will will still require a code in the form load.

'Put this code in your form
Private clsLblBox1 As Class1
Private clsLblBox2 As Class1

Private Sub Form_Load()
    Set clsLblBox1 = New Class1
    Set clsLblBox1.LabelBoxCtl = Label1
    Set clsLblBox2 = New Class1
    Set clsLblBox2.LabelBoxCtl = Label2
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Label1.ForeColor = vbgray
    Label2.ForeColor = vbgray
End Sub

'put this code in a class module named Class1
Private WithEvents lbl As Label

Public Property Set LabelBoxCtl(lblBox As Label)
    Set lbl = lblBox
End Property

'this subroutine controls *all* specified label mousemoves
Private Sub lbl_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
   lbl.ForeColor = vbGreen
End Sub

This is the most I can give you - using API and subclassing.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Why don't u try making a ocx for a label and on mouse move of the label you can call the API or my code,whichever u feel is working fine...

ALIHAIDER1Author Commented:
That's realy good idea and i will adopt the same.
I will respond early.
Ali, check my response to the other question that you have posted.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming Languages-Other

From novice to tech pro — start learning today.