Link to home
Start Free TrialLog in
Avatar of ALIHAIDER1
ALIHAIDER1

asked on

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(.......)
              lblexam.forecolor=vbgreen
         end sub
and how can i change the forecolor of the control through this sub .
pls help me
Avatar of paulott
paulott

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(.......)
              lblexam1.forecolor=vbgreen
              lblexam2.forecolor=vbgray
              lblexam3.forecolor=vbgray
         end sub
         private sub lblExam2_mousemove(.......)
              lblexam2.forecolor=vbgreen
              lblexam1.forecolor=vbgray
              lblexam3.forecolor=vbgray
         end sub
         private sub lblExam3_mousemove(.......)
              lblexam3.forecolor=vbgreen
              lblexam1.forecolor=vbgray
              lblexam2.forecolor=vbgray
         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(.......)
              lblexam1.forecolor=vbgray
              lblexam2.forecolor=vbgray
              lblexam3.forecolor=vbgray
         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
Else
    Label1.ForeColor = vbWhite
End If

end sub

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

anyway it is upto ALIHAIDER1 to decide....
Avatar of ALIHAIDER1

ASKER

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.
Thanks
Ali
Dear expert
pls respond upon my qeury. Kindly do needful because i here is  something remains penging here.
Ali
Hello Ali.

Did my try my example up above?

Thanks,
- 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...
Ok will try again.
Ali
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
Ali
ASKER CERTIFIED SOLUTION
Avatar of harris_c
harris_c
Flag of Philippines image

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
SOLUTION
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
That's realy good idea and i will adopt the same.
I will respond early.
Ali
Ali, check my response to the other question that you have posted.