?
Solved

Mouse move event of label control (vb6)

Posted on 2003-10-24
16
Medium Priority
?
989 Views
Last Modified: 2008-02-07
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
0
Comment
Question by:ALIHAIDER1
[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
  • 4
  • 2
  • +2
16 Comments
 
LVL 1

Expert Comment

by:paulott
ID: 9616280
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.
0
 
LVL 3

Expert Comment

by:pg_india
ID: 9618848
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..................
0
 
LVL 8

Expert Comment

by:harris_c
ID: 9630888
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 3

Expert Comment

by:pg_india
ID: 9631492
i saw this code...but why u use api when it can easily be done...

anyway it is upto ALIHAIDER1 to decide....
0
 

Author Comment

by:ALIHAIDER1
ID: 9631687
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
0
 

Author Comment

by:ALIHAIDER1
ID: 9657242
Dear expert
pls respond upon my qeury. Kindly do needful because i here is  something remains penging here.
Ali
0
 
LVL 1

Expert Comment

by:paulott
ID: 9658853
Hello Ali.

Did my try my example up above?

Thanks,
- Paul
0
 
LVL 3

Expert Comment

by:pg_india
ID: 9662049
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...
0
 

Author Comment

by:ALIHAIDER1
ID: 9662772
Ok will try again.
Ali
0
 

Author Comment

by:ALIHAIDER1
ID: 9662790
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
0
 
LVL 8

Accepted Solution

by:
harris_c earned 200 total points
ID: 9675413
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.



hec",)
0
 
LVL 3

Assisted Solution

by:pg_india
pg_india earned 200 total points
ID: 9676308
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...



0
 

Author Comment

by:ALIHAIDER1
ID: 9677921
That's realy good idea and i will adopt the same.
I will respond early.
Ali
0
 
LVL 3

Expert Comment

by:ashoooo
ID: 9883407
Ali, check my response to the other question that you have posted.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

650 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