fanage 2016-04-03 09:46 采纳率: 0%
浏览 1778

我用C#做了一个屏保,代码如下,为什么我运行的时候按什么键都无法退出?

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 屏保
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

    private void label1_Click(object sender, EventArgs e)
    {

    }

    int deltX = 10;
    int deltY = 8;

    private void timer1_Tick(object sender, EventArgs e)
    {
        this.label1.Left += deltX;
        this.label1.Top += deltY;
        if (this.label1.Top < 0 ||
           this.label1.Top + this.label1.Height > this.Height)
            deltY = -deltY;
        if (this.label1.Left < 0 ||
            this.label1.Left + this.label1.Width > this.Width)
            deltX = -deltX;
    }
    private void Form1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
    {
        Application.Exit();
    }
}

}

  • 写回答

1条回答 默认 最新

  • threenewbee 2016-04-03 10:31
    关注

    窗体的keypreview设置为true

    评论

报告相同问题?

悬赏问题

  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 逻辑谓词和消解原理的运用
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?