Raha_1991
پنج شنبه 20 تیر 1392, 12:20 عصر
برنامه ایست که درون یک فرم اگر ALT+F4 فشرده شد، جعبه پیغامی ظاهر شود که از کاربر سوال بپرسد و در صورت کلیک روی دکمه Yes از برنامه خارج شود.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication6
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void form1_KeyDown(object sender, KeyEventArgs e)
{
if (e.Alt == true && e.KeyCode == Keys.F4)
{ DialogResult dr = new DialogResult();
dr = MessageBox.Show("آیا میخواهیدخارج شوید؟", "خروج", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dr == DialogResult.Yes)
Close();
else
e.Handled = true;
}
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication6
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void form1_KeyDown(object sender, KeyEventArgs e)
{
if (e.Alt == true && e.KeyCode == Keys.F4)
{ DialogResult dr = new DialogResult();
dr = MessageBox.Show("آیا میخواهیدخارج شوید؟", "خروج", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dr == DialogResult.Yes)
Close();
else
e.Handled = true;
}
}
}
}