Private Sub PictureA01_MouseMove (Button As an Integer, Shift the As an Integer, As Single X, Y As Single)
If 1 & lt;=X And X & lt;=PictureA01. Width And 1 & lt;=Y And Y & lt;=PictureA01. Height Then
AppPath=App. Path & amp; "\ img \ Menu1-1. JPG"
PictureA01. Picture=LoadPicture (appPath)
The Else
AppPath=App. Path & amp; "\ img \ Menu1 JPG"
PictureA01. Picture=LoadPicture (appPath)
End the If
End Sub
Above is my writing, but it must be wrong, I don't know what to do, online said those methods cannot be fully realized my results
CodePudding user response:
This code you must not, on "the mouse out" basically cannot correct response,Consider this code:
Option Explicit
Private Declare Function SetCapture Lib "User32" (ByVal hWnd) As Long As Long
Private Declare Function ReleaseCapture Lib "User32 () As" Long
Private mlPicFlag As Long
Private Sub Form_Load ()
Picture1. Picture=LoadPicture (" E: \ Temp \ 1. JPG ")
MlPicFlag=0 & amp;
End Sub
Private Sub Picture1_MouseMove (Button As an Integer, Shift the As an Integer, As Single X, Y As Single)
Dim cx& Cy& IFlag&
If (0=mlPicFlag) Then
Picture1. Picture=LoadPicture (" E: \ Temp \ 2. JPG ")
Call SetCapture (Picture1. HWnd)
MlPicFlag=1
The Else
Cx=X: cy=Y
IFlag=1
Do
If (cx & lt; 0) Then Exit the Do
If (cy & lt; 0) Then Exit the Do
If (cx & gt; Picture1. Width) Then Exit the Do
If (cy & gt; Picture1. Height) Then Exit the Do
IFlag=0: Exit Do
Loop
If (iFlag) Then
MlPicFlag=0
Call ReleaseCapture
Picture1. Picture=LoadPicture (" E: \ Temp \ 1. JPG ")
End the If
End the If
End Sub
CodePudding user response:
Picture not the mouse to the event, so have to write their own,Use a timer, API to get the coordinates of the mouse, to form the coordinates,
Determine whether, in the Picture
Then the transformation background,