Results 1 to 6 of 6
  1. #1
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Mouse Event (VB6)

    What I thought would be simple, doesn't seem to be !

    I would like if possible is to expand an image control when the mouse pointer is over it,

    ie

    Image1.Width = 12000
    Image1.Height = 12000

    Yes it works, but when the mouse is pulled away from the control, the image stays at the above settings.
    Is this simple or ??

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Mouse Event (VB6)

    Which event are you using for this? The MouseMove event of the picture? If so, you must also use the MouseMove event of whatever surrounds the picture (the form itself, or other controls) to reset the picture to its original size.

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Mouse Event (VB6)

    In a little test, I didn't notice flickering, but does something like the following help? It uses a Boolean variable to keep track of whether the mouse is over the image or not, and only changes the image size if the variable changes.

    Private blnOverPicture As Boolean
    Private sngWidth As Single
    Private sngHeight As Single

    Private Sub Form_Load()
    sngWidth = Image1.Width
    sngHeight = Image1.Height
    End Sub

    Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If blnOverPicture = True Then
    blnOverPicture = False
    Image1.Width = sngWidth
    Image1.Height = sngHeight
    End If
    End Sub

    Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If blnOverPicture = False Then
    blnOverPicture = True
    Image1.Width = 2 * sngWidth
    Image1.Height = 2 * sngHeight
    End If
    End Sub

  4. #4
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Mouse Event (VB6)

    Hans, Although it works, doesn't it seem a little crude ?

    After all, in normal operation of the form, when the image properties are "Flat" and border = Fixed,
    the images seem to flicker constantly when using the mouse ?

    ================================================== ==========================

    This seems to stop the flicker:

    <pre> Select Case Me.img1.Width

    Case 735
    Exit Sub
    Case 900
    Me.img1.Width = 735
    Me.img1.Height = 735
    End Select</pre>


    Can an array be made of it ?
    (Aircode)

    <pre>Dim i as integer
    Dim nVal as Integer

    For i = 1 to 4
    nVal = Me.Controls("Img" & i).width
    Next

    Select Case nVal

    Case 735
    Exit Sub
    Case 900
    nVal.width = 735
    nVal.Height = 735
    End Select</pre>


  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Mouse Event (VB6)

    You edited your post while I was posting a reply, so I didn't notice the addition until much later. nVal is an Integer, not a control, so you cannot set nVal.Width. You don't want a loop, since you mouse over only one control at a time.

  6. #6
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Mouse Event (VB6)

    Ok, thanks for the extra information.

Posting Permissions

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