Try
vb Code:
  1. Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
  2. Private Declare Function ReleaseCapture Lib "user32" () As Long
  3. Private Declare Function GetCapture Lib "user32" () As Long
  4.  
  5. Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  6. If (X < 0) Or (Y < 0) Or (X > Picture1.Width) Or (Y > Picture1.Height) Then
  7.        ReleaseCapture
  8.        'the mouse is no longer over the picture box, so do whatever
  9. ElseIf GetCapture() <> Picture1.hwnd Then
  10.        SetCapture Picture1.hwnd
  11.        'the mouse is over the picture box, so do whatever
  12. End If
  13. End Sub