回覆列表
  • 1 # 使用者7364316064609

    ***版本一***左鍵單擊後可以移動,再次單擊停止移動:

    Dim bMove As Boolean "判斷可不可以移動

    Dim oldX!, oldY! "!是Single的縮寫

    Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

    If bMove Then

    Command1.Left = Command1.Left - oldX + X

    Command1.Top = Command1.Top - oldY + Y

    End If

    End Sub

    Private Sub Command1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)

    If Button = 1 Then "1就是滑鼠左鍵

    bMove = Not bMove

    oldX = X

    oldY = Y

    End If

    End Sub

    ***版本二***左鍵按下時可以拖動:

    Dim oldX!, oldY! "!是Single的縮寫

    Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

    If Button = 1 Then "1就是滑鼠左鍵

    oldX = X

    oldY = Y

    End If

    End Sub

    Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

    If Button = 1 Then

    Command1.Left = Command1.Left - oldX + X

    Command1.Top = Command1.Top - oldY + Y

    End If

    End Sub

  • 中秋節和大豐收的關聯?
  • 在校學生做兼職好嗎?你怎麼看?