1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Visual Basic & Mouse Over

Discussion in 'Software Development' started by bear, Nov 3, 2007.

Thread Status:
Not open for further replies.
Advertisement
  1. bear

    bear Thread Starter

    Joined:
    Jan 1, 1999
    Messages:
    110
    Help,
    I am needing some help in Mouse Over in Visual Basic 6. I am trying to have either labels or command buttons that are invisible, but when a mouse passes over it, they appear. I am really wanting to have the line control over a label, so when the user passes the mouse over it, the line will appear, then click on the line, with the label under it.
    If anyone can stear me in the right direction, I would greatly appreciate it, and even some code would help. I am totally lost and confused!!!! :eek:

    Thanks,

    bear
     
  2. Het Irv

    Het Irv

    Joined:
    Sep 29, 2007
    Messages:
    54
    It has been a while since I used VB but have you tried using something like

    If MouseMove = true then
    lablexyz.visible = true

    or something of that nature (I forget what the syntax would be exactly). But, with that if the mouse is not moving but over the control the control would still be hidden.

    I hope this gives you some ideas.
     
  3. bear

    bear Thread Starter

    Joined:
    Jan 1, 1999
    Messages:
    110
    Thanks ver much for the idea. I must be in a slump, as I can not get anything to work. I will just have to worry it to death, until it works.
     
  4. Mosaic1

    Mosaic1

    Joined:
    Aug 17, 2001
    Messages:
    7,486
    In order to have the command button show when the mouse is moved over it, you need to find out where the command button is located on the form. (Get the range for the X and Y coordinates of command1)

    Here's a code sample I wrote for you of using the form's MouseMove event.
    When the mouse is over the command button, the button is visible. When the mouse is moved away to another location, the command button again disappears.

    Code:
    Private Sub Form_MouseMove(Button As Integer, Shift As Integer, _
     X As Single, Y As Single)
    Dim A As Single
    Dim B As Single
    A = Command1.Left + Command1.Width
    B = Command1.Top + Command1.Height
    
     If X > Command1.Left And X < A _
     And Y > Command1.Top And Y < B Then
     Command1.Visible = True
     Else: Command1.Visible = False
     End If
    
     
    End Sub
    Also, this assumes you have set the command button's visible property to false in the IDE.
     
  5. bear

    bear Thread Starter

    Joined:
    Jan 1, 1999
    Messages:
    110
    Thanks for your reply on the MouseOver routine. That is just what I was looking for. Thanks again

    Bear
     
  6. Mosaic1

    Mosaic1

    Joined:
    Aug 17, 2001
    Messages:
    7,486
    You're welcome. Good luck with your project.
     
  7. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/647454

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice