Solved

Mouse move event of label control (vb6)

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

617 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