把图片放在PictureBox里面,然后移动PictureBox

解决方案 »

  1.   

    Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)  xp = X  '重新设置 x点的值 ,为鼠标按下的点
      
      yp = Y   '重新设置 y点的值,,为鼠标按下的点End SubPrivate Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)If Button = 1 Then             '如果按下鼠标左键
      
         X1 = Picture1.Left + (X - xp)  'x1点的值为,图像左边的值加上鼠标移动的距离
         
         Y1 = Picture1.Top + (Y - yp)   'y1点的值为,图像上边的值加上鼠标移动的距离
         
     If X1 < 0 And X1 + Picture1.Width > Form2.Width Then  '判断图像是否超出图片框宽
          
      
      Picture1.Left = X1                                     '为真 调用x1
     
      
     End If
     
    If Y1 < 0 And Y1 + Picture1.Height > Form2.Height - 1200 Then '判断图像是否超出图片框高  
      Picture1.Top = Y1
         
    End If   End If
    End Sub
      

  2.   

    用SetWindowLong把控件设为可移动的。