Results 1 to 6 of 6

Thread: rollover image...please helppp!!!!

  1. #1

    Thread Starter
    Hyperactive Member dflw's Avatar
    Join Date
    Apr 2001
    Location
    ct, usa
    Posts
    412

    rollover image...please helppp!!!!

    hello,

    what is the code to make a rollover image effect? I have a picture and when the mouse moves over it, I want the image to change into a different image. I asked this before, but the code did not make sense.
    Visual Basic 6, HTML, JavaScript, learning C++

  2. #2
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    What is it exactly what you're needing. I've post you a code that does the "rollover image" effect. What of all that did not make sense?Do you need something special effect?
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  3. #3
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390
    A simple way to do it:

    have 3 ImageControls

    1 main
    2 that are not visible

    on mousemove
    Image1.picture = Image2.picture


    then to set it back....image1.picture = image3.picture
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  4. #4
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    This is the best way I know to create a "rollover image" effect. The "how" you load the new image is up to you, there are several different way to do it: Loadpicture, a picture array, an ImageList, whatever. But the essence of the effect is shown in this code:

    Code:
    Private Declare Function ReleaseCapture Lib "user32" () As Long
    Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
    
    Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        With Picture1
            If (X < 0) Or (Y < 0) Or (X > .Width) Or (Y > .Height) Then
                ReleaseCapture
                .Picture = RollOver(0).Picture
            Else
                SetCapture .hwnd
                .Picture = RollOver(1).Picture
            End If
        End With
        
    End Sub

    The PictureBox RollOver is an array, but you can use whateve method you like to load one or other image.
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  5. #5
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390
    good Idea ReleaseCapture / SetCapture....


    then you wont have to program the form mousemove to set the image back
    much cleaner Display

    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  6. #6
    Member
    Join Date
    Aug 2001
    Posts
    60

    Arrow mouse over effect

    I would Like my images to swap when the cursor is moved over one image.

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