Solved

Mouse move event of label control (vb6)

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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Help with my python script 6 163
why to use string 10 60
mapAB Challlenge 35 145
t-sql sp_addlinkedserver possible risks 3 71
Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
This article will show, step by step, how to integrate R code into a R Sweave document
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

803 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