获取鼠标在图片上的当前位置: Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) Print X, Y End Sub我觉得截取下来的那张小图片也可以用PictureBox来显示
1.同意小牛的 2.用bitblt抓图
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) MsgBox X, Y End Sub
Option ExplicitPrivate Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function ReleaseCapture Lib "user32" () As Long Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As LongPrivate Sub Form_Load() 'picture1,picture2 'picture2为显示小图片用的 Picture2.Visible = False End SubPrivate Sub Picture1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single) If x > 0 And x < Picture1.Width And y > 0 And y < Picture1.Height Then Picture2.Left = x + Picture2.Width Picture2.Top = y + Picture2.Height + 200 Picture2.Cls BitBlt Picture2.hDC, 0, 0, ScaleX(Picture2.ScaleWidth, vbTwips, vbPixels), _ ScaleY(Picture2.ScaleHeight, vbTwips, vbPixels), _ Picture1.hDC, ScaleX(x - 100, vbTwips, vbPixels), ScaleY(y - 100, vbTwips, vbPixels), vbSrcCopy Picture2.Visible = True SetCapture Picture1.hwnd Else Picture2.Visible = False ReleaseCapture End If End Sub============== 试一下吧~`~~~~~~~~~
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Print X, Y
End Sub我觉得截取下来的那张小图片也可以用PictureBox来显示
2.用bitblt抓图
MsgBox X, Y
End Sub
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As LongPrivate Sub Form_Load()
'picture1,picture2
'picture2为显示小图片用的
Picture2.Visible = False
End SubPrivate Sub Picture1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
If x > 0 And x < Picture1.Width And y > 0 And y < Picture1.Height Then
Picture2.Left = x + Picture2.Width
Picture2.Top = y + Picture2.Height + 200
Picture2.Cls
BitBlt Picture2.hDC, 0, 0, ScaleX(Picture2.ScaleWidth, vbTwips, vbPixels), _
ScaleY(Picture2.ScaleHeight, vbTwips, vbPixels), _
Picture1.hDC, ScaleX(x - 100, vbTwips, vbPixels), ScaleY(y - 100, vbTwips, vbPixels), vbSrcCopy
Picture2.Visible = True
SetCapture Picture1.hwnd
Else
Picture2.Visible = False
ReleaseCapture
End If
End Sub==============
试一下吧~`~~~~~~~~~