Results 1 to 6 of 6

Thread: Mimic MouseOver

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2007
    Posts
    21

    Mimic MouseOver

    Hi

    i am right in thinking there isn't a mouseover function or a mouseLeave function in vb6?

    i want to mimic this for a menu. i.e like in a browser your mouse goes over a clickable link and it changes colour.

    i've tried to do this with a timer function, changing the labels colour on MouseMove then setting the timer to 1/2 second which after it should return the label back to it's normal colour. but its not working, the timer function is just executing straight away and not pausing for 1/2 second before executing the code?

    Any ideas? what am i doing wrong?

    Code:
    Private Sub Lbl_Menu_Details_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    
        Lbl_Menu_Details.ForeColor = RGB(200, 0, 0)
        
        Timer_Menu.Enabled = True
               Call Timer_Menu_Timer
        Timer_Menu.Enabled = False
    End Sub
    
    Private Sub Timer_Menu_Timer()
    
    'This interval is set to 1/2 second 
             
                    Lbl_Menu_Details.ForeColor = 0
        
    End Sub
    Thanks!!

    Jon

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Mimic MouseOver

    You are explicitly calling the Timer_Menu_Timer sub, which runs it immediately. If you simply enable the timer (as you have already) then it will run when the interval is reached.

    You will also need to move the line that disables the timer into the timer sub itself (otherwise it will disable it before it is fired).

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jul 2007
    Posts
    21

    Re: Mimic MouseOver

    Cool that worked thanks,

    but experimenting with another way but the width and height parts of the IF OR
    are not working any ideas why?

    Code:
    Private Sub Lbl_Menu_Equip_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    
    If (X < 10) Or (Y < 10) Or (X > Lbl_Menu_Equip.Width - 10) Or (Y > Lbl_Menu_Equip.Height - 10) Then
    Lbl_Menu_Equip.ForeColor = 0
    Else
    Lbl_Menu_Equip.ForeColor = RGB(255, 0, 0)
    End If
    
    End Sub
    Thanks!

  4. #4
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,509

    Re: Mimic MouseOver

    you could set the labels mouseicon property, then when the mouse moves over the label the mouse pointer would change to the icon, make sure to set the mousepointer property to 99 (custom)

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Jul 2007
    Posts
    21

    Re: Mimic MouseOver

    i've sorted it just had to play about with the width and height minus

  6. #6
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Mimic MouseOver

    That will only work if the mouse actually goes into the area you specify (X from 0 to 9, or Y from 0 to 9, etc), and you cannot guarantee that will happen - especially as the default ScaleMode (thus value of X and Y, and .Width etc) is Twips, which is much smaller than a Pixel (typically 15 Twips in a Pixel, but it varies). If you change the 10 to about 90, it seems to almost work properly.

    A better way of doing that would be to simply set the colour in there, and set it to 0 in the MouseMove event of the Form (or whatever control the label is on).. but that still allows room for error, as the mouse can move quickly, or the user can alt-tab to another program.


    wes4dbt's suggestion is a good one, assuming of course that changing the mouse cursor is an appropriate solution for you.

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