VisualBasic.NET

マウスドラッグでフォームを動かす

Private Mouse_x As Integer
Private Mouse_y As Integer

Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
    Mouse_x = Cursor.Position.X
    Mouse_y = Cursor.Position.Y
End Sub
Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
    If e.Button = MouseButtons.Left Then
        MyBase.Top += (Cursor.Position.Y - Mouse_y)
        MyBase.Left += (Cursor.Position.X - Mouse_x)
        Mouse_x = Cursor.Position.X
        Mouse_y = Cursor.Position.Y
    End If
End Sub

トップ   編集 凍結解除 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2007-05-22 (火) 20:28:46 (4472d)