Results 1 to 5 of 5

Thread: mouseover,mouseclick and mousemove

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Location
    Glasgow,Scotland
    Posts
    281

    Hi,

    I have an image control in my vb project, and I want it to act as a button. There will be 3 images in the image control at different times.

    When the cursor is not near the image, there is image 1.

    When the cursor is over the image, there is image 2.

    When the cursor is pressed over the image, it changes to image 3 for the brief period that the mouse has been clicked.

    Then it changes back to image 2 - or 1, if the user takes the cursor off the image.

    I know it has something to do with mouseover etc, but I'm not sure of the code.

    Could somebody help me?

    Thanks!




  2. #2
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Something like this
    Code:
    Private Sub Image1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    image1.picture = image3.picture 
    End Sub
    
    Private Sub Image1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    image1.picture = image1.picture
    End Sub
    
    Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    image1.picture = image2.picture
    End Sub

    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  3. #3
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Nitro
    Posts
    633

    Try this

    Code:
    Option Explicit
    
    Private Sub Form_Load()
      ChDrive "C:\"
      ChDir "C:\Program Files\Microsoft Visual Studio\Common\Graphics\Icons\Misc\"
    End Sub
    
    Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
      Image1.Picture = LoadPicture("FACE02.ICO")
    End Sub
    
    Private Sub Image1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
      Image1.Picture = LoadPicture("FACE03.ICO")
    End Sub
    
    Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
      Image1.Picture = LoadPicture("FACE01.ICO")
    End Sub
    Chemically Formulated As:
    Dr. Nitro

  4. #4
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Nitro
    Posts
    633
    Sorry Vlatko! I didn't realize you posted already.
    Chemically Formulated As:
    Dr. Nitro

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Location
    Glasgow,Scotland
    Posts
    281

    Thumbs up


    Thanks, lads.

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