Winform 中的KeyDown
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;
using System.Xml;
using System.Runtime.InteropServices; namespace WindowsFormsApplication1
{
public partial class Main : Form
{
public Main()
{
this.KeyPreview = true;
InitializeComponent();
//TopMost = true;
LoadMax();
} private void picXS_Click(object sender, EventArgs e)
{
Form1 form = new Form1();
this.Hide();
form.Show();
} private void pictureBox1_Click(object sender, EventArgs e)
{
if (MessageBox.Show("确认注销吗?", "请确认", MessageBoxButtons.YesNo) == DialogResult.Yes)
{ Login login = new Login();
this.Hide();
login.Show();
}
} private void pictureBox2_Click(object sender, EventArgs e)
{
SelectShowInfo select = new SelectShowInfo();
this.Hide();
select.Show();
} private void pictureBox3_Click(object sender, EventArgs e)
{ SubInfo info = new SubInfo();
this.Hide();
info.Show(); } private void Main_Load(object sender, EventArgs e)
{ } public void LoadMax()
{
if (this.WindowState == FormWindowState.Maximized)
{
this.WindowState = FormWindowState.Normal;
}
else
{
this.FormBorderStyle = FormBorderStyle.None;
this.WindowState = FormWindowState.Maximized;
}
} private void pictureBox5_Click(object sender, EventArgs e)
{
SubSummary subsum = new SubSummary();
this.Hide();
subsum.Show();
} private void Form1_KeyDown(object sender, KeyEventArgs e)
{ } private void Main_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.F7)
{
WEB main = new WEB();
this.Hide(); main.Show();
} if (e.KeyCode == Keys.NumPad1)
{
picXS_Click(sender, e); } if (e.KeyCode == Keys.NumPad2)
{
pictureBox2_Click(sender, e); } if (e.KeyCode == Keys.NumPad3)
{
pictureBox5_Click(sender, e); } if (e.KeyCode == Keys.NumPad4)
{
pictureBox3_Click(sender, e); } if (e.KeyCode == Keys.NumPad5)
{
pictureBox1_Click(sender, e); } if (e.KeyCode == Keys.NumPad6) {
picBminPwd_Click(sender,e);
} //禁止相关快捷键
if (e.Modifiers == Keys.Alt
|| e.Modifiers == Keys.LWin
|| e.Modifiers == Keys.RWin
)
{
e.Handled = true;
} //弹出Password窗体
//if (e.Alt == true)
//{
// PassWords password = new PassWords();
// e.Handled = false;
// password.Show();
//}
} private void picBminPwd_Click(object sender, EventArgs e)
{ PassWords pwd = new PassWords();
pwd.ShowDialog(); } ////倒计时
//[StructLayout(LayoutKind.Sequential)] //struct LASTINPUTINFO
//{
// [MarshalAs(UnmanagedType.U4)]
// public int cbSize; // [MarshalAs(UnmanagedType.U4)]
// public uint dwTime;
//} //[DllImport("user32.dll")] //static extern bool GetLastInputInfo(ref LASTINPUTINFO plii); //static long GetLastInputTime()
//{
// LASTINPUTINFO vLastInputInfo = new LASTINPUTINFO();
// vLastInputInfo.cbSize = Marshal.SizeOf(vLastInputInfo); // if (!GetLastInputInfo(ref vLastInputInfo)) // return 0; // return Environment.TickCount - (long)vLastInputInfo.dwTime;
//} //private void timer1_Tick(object sender, EventArgs e)
//{
// if (GetLastInputTime() > 3000)
// {
// timer1.Stop(); // Screen screen = new Screen(); // this.Hide(); // screen.Show();
// }
//} }
}
Winform 中的KeyDown的更多相关文章
- C#winform中ListView的使用
使用ListView模仿Windows系统的资源管理器界面,实现文件(夹)的浏览.重命名.删除及查询等功能,主要功能界面展示如下: 1.MainForm.cs及MainForm.Designer.cs ...
- 控制WinForm中Tab键的跳转
一,需求 在Winform中,默认情况下,按下Tab键,光标会按照我们设定的TabIndex值从小到大进行跳转. 但如果用户要求按下Tab键跳转到特定的控件,这种要求还是很合理的,比如用户只想输入几个 ...
- 转载:WinForm中播放声音的三种方法
转载:WinForm中播放声音的三种方法 金刚 winForm 播放声音 本文是转载的文章.原文出处:http://blog.csdn.net/jijunwu/article/details/4753 ...
- C# Winform 中如何实现音乐播放和视频播放
C# Winform 中如何实现音乐播放和视频播放 namespace WindowsFormsApplication1 { public partial class Form2 : Form { ...
- 另一种在WINFORM中使用XNA的方法
之前在写化学分子模型制作程序的时候,使用一种方法,将WINFORM控件嵌入到XNA窗体中,从而实现了即使用WINFORM窗体控件又使用XNA.最近在写另一个物理运动学课件制作程序,同样使用XNA,但从 ...
- winform中dataGridView单元格根据值设置新值,彻底解决绑定后数据类型转换的困难
// winform中dataGridView单元格在数据绑定后,数据类型更改困难,只能迂回实现.有时候需要将数字变换为不同的文字描述,就会出现int32到string类型转换的异常,借助CellFo ...
- winform中ComboBox实现text和value,使显示和值分开,重写text和value属性
winform的ComboBox中只能赋值text,显示和值是一样的,很多时候不能满足根本需要,熟悉B/S开发的coder最常用的就是text和value分开的,而且web下DropDownList本 ...
- winform中dataGridView隔行显示不同的背景色,鼠标移动上显示不同颜色,离开后变回原色
winform中dataGridView隔行显示不同的背景色,鼠标移动上显示不同颜色,离开后变回原色 先设置奇数行颜色,这个有个自带的属性AlternatingRowsDefaultCellStyle ...
- winform中button点击后再点击其他控件致使button失去焦点,此时button出现黑色边线,去掉黑色边线的方法
winform中button点击后再点击其他控件致使button失去焦点,此时button出现黑色边线,去掉黑色边线的方法 button的FlatAppearence属性下,设置BorderSize= ...
随机推荐
- location.href跳转不正确
今天写这个随笔的用意是为了记录我遇到的一种情况,导致我页面无法正确跳转 location.href跳转页面其实很简单,只要附上url就可以了,但是今天我在测试一个跳转时是这么写的: location. ...
- jQuery实现抖动效果
//抖动效果 //intShakes:抖动次数:intDistance:抖动左右距离:intDuration:持续时间 jQuery.fn.shake = function (intShakes, i ...
- 安装和使用memcached
引用:http://www.czhphp.com/archives/252 如何将 memcached 融入到您的环境中? 在开始安装和使用 using memcached 之前,我们需要了解如何将 ...
- LeetCode344:Reverse String@Python
Write a function that takes a string as input and returns the string reversed. Example: Given s = &q ...
- 在.net桌面程序中自定义鼠标光标
有的时候,一个自定义的鼠标光标能给你的程序增色不少.本文这里介绍一下如何在.net桌面程序中自定义鼠标光标.由于.net的桌面程序分为WinForm和WPF两种,这里分别介绍一下. WinForm程序 ...
- nginx 启动,停止和重新加载配置
要启动nginx的,运行可执行文件.一旦nginx的启动时,它可以通过与-s参数调用可执行来控制.使用以下语法 nginx -s signal 其中,信号可以是下列之一: stop - fast sh ...
- bash脚本编程之二 条件判断and 逻辑运算
1.条件测试结构 1) if/then结构: 判断命令列表的退出码是否为0,0为成功. 如果if和then在条件判断的同一行上的话, 必须使用分号来结束if表达式: if和then都是关键字. 关键字 ...
- 解决方法:An error occurred on the server when processing the URL. Please contact the system administrator
在WINDOWS7或SERVER2008上安装了IIS7.5,调试ASP程序时出现以下错误: An error occurred on the server when processing the U ...
- 解决Ubuntu下 Could NOT find CURL (missing: CURL_LIBRARY CURL_INCLUDE_DIR)
Ubuntu下CMake 编译时出现问题:Could NOT find CURL (missing: CURL_LIBRARY CURL_INCLUDE_DIR) 查找发现 # sudo apt-g ...
- NXP开源自动驾驶计算平台Bluebox 打造现实无人汽车
知名半导体制造商恩智浦NXP已经准备好了自家的自动驾驶计算开源平台Bluebox,将为汽车制造商提供现成的一体化自动 驾驶计算解决方案.专为自动驾驶设备的BlueBox中央计算引擎.不仅能够为无人驾驶 ...