PDA

Click to See Complete Forum and Search --> : Control help


cjwares
Dec 13th, 1999, 12:28 PM
ok, with most controls, they have; MouseDown, MouseMove, and MouseUp. that doesn't do me much good, is there anyway to have it act as a MouseEnter/MouseExit event? Please help.

Example would be, you put your mouse over a picbox, and it changes to a different picture, move the mouse off the picbox, and it would change back.

jkurpias
Dec 13th, 1999, 03:19 PM
Here's a bit of code that changes the caption of a command button as the mouse is moved onto & off the button. Should be the same for a PictureBox control.


Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Command1.Caption = "ON"
End Sub

Private Sub Form_MouseMove(Button As Integer
, Shift As Integer, X As Single, Y As Single)
Command1.Caption = "OFF"
End Sub

Dec 13th, 1999, 05:27 PM
That only works if you move the mouse over the form(after you where above the button) it doesn't work if you move over another control(or move real fast).

The only decent way i found to this kinda thing is with the GetCurserPos api.



------------------

Vincent van den Braken
EMail: azzmodan@azzmodan.demon.nl
ICQ: 15440110 (http://www.icq.com/15440110)
Homepage: http://www.azzmodan.demon.nl

Joacim Andersson
Dec 13th, 1999, 05:42 PM
You can use the SetCapture API function. Here's an example using a command button:

'Form Code
Option Explicit

Private Declare Function SetCapture _
Lib "user32" ( _
ByVal hwnd As Long) As Long

Private Declare Function ReleaseCapture _
Lib "user32" () As Long

Private blnHasCapture As Boolean

Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If blnHasCapture = False Then
Call SetCapture(Command1.hwnd)
blnHasCapture = True
End If
If (X < 0 Or X > Command1.Width) Or (Y < 0 Or Y > Command1.Height) Then
Command1.Caption = "Off"
Call ReleseCapture()
blnHasCapture = False
Else
Command1.Caption = "On"
End If
End Sub

Private Sub Command1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If blnHasCapture Then
Call SetCapture(Command1.hwnd)
End If
End Sub

Good luck!




------------------
Joacim Andersson
joacim@programmer.net
joacim@yellowblazer.com
www.YellowBlazer.com (http://www.YellowBlazer.com)