
前田稔(Maeda Minoru)の超初心者のプログラム入門
![]()
![]()
/**************************************************/
/*★ Mouse の Click で終了を確認する 前田 稔 ★*/
/**************************************************/
using System;
using System.Drawing;
using System.Windows.Forms;
public class MyForm : Form
{
public MyForm()
{
MouseDown += new MouseEventHandler(OnMyMouseDown);
}
private void OnMyMouseDown(object sender, MouseEventArgs e)
{
DialogResult rc;
rc= MessageBox.Show("終了しますか","選択",MessageBoxButtons.YesNo,MessageBoxIcon.Question);
if (rc == DialogResult.Yes) Application.Exit();
}
}
class mouse
{
public static void Main()
{
MyForm mf = new MyForm();
Application.Run(mf);
}
}
|
| MouseDown += new MouseEventHandler(OnMyMouseDown); |
DialogResult rc;
rc= MessageBox.Show("終了しますか","選択",MessageBoxButtons.YesNo,MessageBoxIcon.Question);
if (rc == DialogResult.Yes) Application.Exit();
|
![]()
| this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form_Closing); |
| FormClosing += new FormClosingEventHandler(Form_Closing); |
private void Form_Closing(object sender, FormClosingEventArgs e)
{
DialogResult rc;
rc= MessageBox.Show("終了しますか","選択",MessageBoxButtons.YesNo,MessageBoxIcon.Question);
if (rc == DialogResult.No) e.Cancel = true;
}
|
![]()