Results 1 to 4 of 4

Thread: Mouse Over

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 1999
    Location
    MA, USA
    Posts
    523

    Post

    I want to change color of let's say label when coursor is on it and then I want to restore its original color after the cursor is somewhere else. I know how to do it actually, but I'm using a lot of code just to change the color to original (I put my code in Form_MouseMove, Frame_MouseMove etc.) is there a way to put the code in just one place so it will work correctly?

    I hope you know what I mean

    ------------------
    Visual Basic Programmer (at least I want to be one)
    ------------------
    PolComSoft
    You will hear a lot about it.


  2. #2
    Member
    Join Date
    Aug 1999
    Posts
    52

    Post

    hi,

    Try this..

    Private Type POINTAPI
    x As Long
    y As Long
    End Type
    Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long

    Private mpoiCursorPos As POINTAPI
    Dim flag As Boolean

    Private Sub Timer1_Timer()
    Dim lonCstat As Long
    Dim lonCurrhWnd As Long

    lonCstat = GetCursorPos(mpoiCursorPos)
    lonCurrhWnd = WindowFromPoint(mpoiCursorPos.x, mpoiCursorPos.y)

    If lonCurrhWnd = UserControl.hWnd Then
    Shape1.FillColor = RGB(255, 0, 0)
    Label1.BackColor = RGB(255, 0, 0)
    Else
    Shape1.FillColor = RGB(0, 0, 0)
    Label1.BackColor = RGB(0, 0, 0)
    End If
    End Sub

    kandan.

  3. #3
    Hyperactive Member venkatraman_r's Avatar
    Join Date
    Jul 1999
    Location
    Chennai, INDIA
    Posts
    284

    Post

    This simpler might help you out...

    Private Sub lblurl_DragDrop(Source As Control, X As Single, Y As Single)
    If Source Is lblUrl Then
    With lblUrl
    .Font.Underline = False
    .ForeColor = vbBlack
    Call ShellExecute(0&, vbNullString, .Caption, vbNullString, vbNullString, vbNormalFocus)
    End With
    End If
    End Sub

    Private Sub lblUrl_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
    If State = vbLeave Then
    With lblUrl
    .Drag vbEndDrag
    .Font.Underline = False
    .ForeColor = vbBlack
    End With
    End If
    End Sub

    Private Sub lblUrl_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    With lblUrl
    .ForeColor = vbBlue
    .Font.Underline = True
    .Drag vbBeginDrag
    End With
    End Sub

    ---------
    Venkat.

  4. #4
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    It's actually alot easier:

    Code:
    Private m_lOrigColor As Long
    Private Sub Form_Load()
        m_lOrigColor = Label1.BackColor
    End Sub
    
    
    Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        Label1.BackColor = m_lOrigColor
    End Sub
    
    
    Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        Label1.BackColor = vbRed
    End Sub
    ------------------

    Serge

    Software Developer
    Serge_Dymkov@vertexinc.com
    Access8484@aol.com
    ICQ#: 51055819


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width