这是一个当图片大于窗体时,用鼠标移动多余部分的代码?Private Sub Form_Load()
     Image1 = LoadPicture("f:\bbs\tu\01.jpg") '这个路径可能要改
     'FitForm Image1
End SubPrivate Sub Image1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
     gX = X
     gY = Y
End SubPrivate Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
     If Not Button = vbLeftButton Then Exit Sub
     Dim dx As Long, dy As Long, ax As Long, ay As Long, t As Long, l As Long, tt As Long, ll As Long          'dy = Y - gY
          dx = X - gX
          ll = Image1.Left
          'tt = Image1.Top
          l = Abs(ll)
          't = Abs(tt)
          ax = (Image1.Width - l - ScaleWidth)
          'ay = (Image1.Height - t - ScaleHeight)
          If ll > 0 Then
               dx = 0
          Else
               If dx < 0 Then
                    If Abs(dx) > ax Then dx = -ax
               Else
                    If dx > l Then dx = l
               End If
          End If
          'If tt > 0 Then
               'dy = 0
          'Else
               'If dy < 0 Then
                    'If Abs(dy) > ay Then dy = -ay
               'Else
                    'If dy > t Then dy = t
              ' End If
           'End If
          Image1.Move ll + dx 'tt + dyEnd Sub

解决方案 »

  1.   

    加载一个图片到image控件,然后通过鼠标右键移动图片
      

  2.   

    我大概能看懂。第一个是默认载入,第二个时,当鼠标按下时,把当前的点给X,Y第三个有些不懂。ll = Image1.Left,  ax = (Image1.Width - l - ScaleWidth),请帮助
      

  3.   

    tt ll 这种命名有点乱糟糟。不过代码简单——我觉得自己研究比较好。
    这段代码有防止移出界的功能,边运行边看应该能够理解。