Image- button html style - not available with Vb?

daedalus_hammer
03-26-2003, 01:08 PM
Hi
I just started to make my own buttons (bitmap immages).
I remember in html you can use an event "mouse over" to do something when the mouse is over a link or a picture, and I was wondering how could I do that with VB (in particular with Image control) because I made a button composed of 3 immages - one for normal display, one for mouse-over and an other for click.
But the problem is there is no "mouse over" event.
I tried using mouse moove but that only works while the mouse is actually mooving, and further more I tried adding a timer to make the time the button is displayied in "mouse over mode" smoother but it's really not smooth.
Can anyone please help me?
Thanks

dexmix
03-26-2003, 01:20 PM
Private Declare Function GetCapture Lib "user32" () As Long
Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long

Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'On Error Resume Next

With Picture1
If X > 0 And X < .ScaleWidth And Y > 0 And Y < .ScaleHeight Then
If GetCapture <> .hwnd Then SetCapture .hwnd
.BackColor = &HC0FFC0
Else
ReleaseCapture
.BackColor = &HE0E0E0
End If
End With

End Sub


greets

daedalus_hammer
03-26-2003, 01:41 PM
But could you comment a little bit more on that code, because I'm too stupid to understand what it does and how to implement that :) -- really :) .
Thanks

dexmix
03-26-2003, 02:26 PM
But could you comment a little bit more on that code, because I'm too stupid to understand what it does and how to implement that :) -- really :) .
Thanks

Stupid or Naive. If i knew you were actually stupid i wouldnt bother explaining it to you because you wouldnt understand it anyway. ;)

Set/Get/ReleaseCapture are Routines for capturing Mouse input.
useing GetCapture forwards all mouse messages to the Window of your choice, in this case the PictureBox named Picture1, until you release it.

Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'On Error Resume Next

With Picture1
'is the mouse over our picture box?
If X > 0 And X < .ScaleWidth And Y > 0 And Y < .ScaleHeight Then
'yes the mouse is over our picbox
'capture mouse events
If GetCapture <> .hwnd Then SetCapture .hwnd
'set back color to green
.BackColor = &HC0FFC0
Else
'no the mouse is no longer over out picbox

'so release mouse events
ReleaseCapture
'back color to grey
.BackColor = &HE0E0E0
End If
End With

End Sub

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum