Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Mouse move event of label control (vb6)

Posted on 2003-10-24
7
Medium Priority
?
699 Views
Last Modified: 2010-07-27
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
7 Comments
 
LVL 2

Expert Comment

by:BUCHAS
ID: 9624682
alright, suppose the default forecolor of your label is vbred and you want to change it to vbgreen every time the user pass the mouse over it:

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

    lblexam.ForeColor = vbRed

End Sub

Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
   
    lblexam.ForeColor = vbGreen
   
End Sub
0
 

Author Comment

by:ALIHAIDER1
ID: 9624874
Dear expert
        Actuly that's not what i want. I want to manage the same within the label control subroutine. It may be handel through x and y coordinates. Or may be u have any other solution.
I dont want to use the form_mouseover sub.
I want to use just label1_mousemove sub.
Pls help me and thanks for respose.
Ali
0
 
LVL 1

Accepted Solution

by:
polital earned 200 total points
ID: 9705950
This should be simple.

Create a global variable
        Private ctrl as control

In the Form load
       set ctrl = nothing

In the mousemove routine

     if not (ctrl  is nothing) then
         ctrl.Forecolor = vbButtonFace  '  or whatever your default color is
     end if

    lbl.ForeColor = vbGreen
    set ctrl = lbl

This should do it.

polital


0
 
LVL 1

Expert Comment

by:polital
ID: 9705954
I forgot to add in the interests of efficiency at the beginning of the mousemove routine

if ctrl is lbl then exit sub

You don't want to keep setting the color - once will do.

polital
0
 
LVL 3

Assisted Solution

by:ashoooo
ashoooo earned 200 total points
ID: 9883394
You want to change the color of the label back to its original color as soon as the mouse if moved out. Am I right?

If yes, there is no simple way to do this other than write some code in the mouseover event handlers of other controls. Even writing code in mouseover eventhandler for the form is NOT enough; because if the mouse is moved over another control and doesnt get over the form, the form will never get a mouseover event and the color of your control will never change.

Try capturing the mouse on mouseover. This will send mouseover event to your control even when it leaves the boundry. Then check if the mouse has left the boundry. If yes, change the color of your control to normal and release the mouse.

Hope this helps.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Navigation is an important part of web design from a usability perspective. But it is often a pain when it comes to a developer’s perspective. By navigation, it often means menuing. This is less theory and more practical of how to get a specific gro…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

721 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