Solved

Mouse move event of label control (vb6)

Posted on 2003-10-24
7
661 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
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 50 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 50 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
isEverywhere  challenge 19 70
has77  challenge 9 71
Re-position the objects 7 95
Advice in Xamarin 21 44
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This article will show, step by step, how to integrate R code into a R Sweave document
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

947 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now