フォームをマウスで移動

「フォームをマウスで移動」の編集履歴(バックアップ)一覧はこちら

フォームをマウスで移動」(2010/08/04 (水) 21:04:16) の最新版変更点

追加された行は緑色になります。

削除された行は赤色になります。

//マウスのクリック位置を記憶 private Point mousePoint; //マウスのボタンが押されたとき private void Form1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { if ((e.Button & MouseButtons.Left) == MouseButtons.Left) { //位置を記憶する mousePoint = new Point(e.X, e.Y); } } //マウスが動いたとき private void Form1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { if ((e.Button & MouseButtons.Left) == MouseButtons.Left) { this.Left += e.X - mousePoint.X; this.Top += e.Y - mousePoint.Y; //または、つぎのようにする //this.Location = new Point( // this.Location.X + e.X - mousePoint.X, // this.Location.Y + e.Y - mousePoint.Y); } }

表示オプション

横に並べて表示:
変化行の前後のみ表示: