MainForm.cs
上传用户:linger1010
上传日期:2008-12-08
资源大小:561k
文件大小:1k
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- using Microsoft.WindowsCE.Forms;
- namespace KeyboardEvents
- {
- public partial class MainForm : Form
- {
- public MainForm()
- {
- InitializeComponent();
- }
- private void m_addMessage(
- string e,
- string keyChar,
- string keyCode,
- string keyData,
- string keyValue,
- string alt,
- string ctrl,
- string shift)
- {
- ListViewItem item = new ListViewItem(
- new string[] { e, keyChar, keyCode, keyData, keyValue, alt, ctrl, shift });
- m_lstMessage.Items.Add(item);
- }
- private void m_txtInput_KeyDown(object sender, KeyEventArgs e)
- {
- m_addMessage(
- "KeyDown",
- "-",
- e.KeyCode.ToString(),
- e.KeyData.ToString(),
- e.KeyValue.ToString(),
- e.Alt.ToString(),
- e.Control.ToString(),
- e.Shift.ToString());
- }
- private void m_txtInput_KeyPress(object sender, KeyPressEventArgs e)
- {
- m_addMessage(
- "KeyPress",
- e.KeyChar.ToString(),
- "-",
- "-",
- "-",
- "-",
- "-",
- "-");
- }
- private void m_txtInput_KeyUp(object sender, KeyEventArgs e)
- {
- m_addMessage(
- "KeyUp",
- "-",
- e.KeyCode.ToString(),
- e.KeyData.ToString(),
- e.KeyValue.ToString(),
- e.Alt.ToString(),
- e.Control.ToString(),
- e.Shift.ToString());
- }
- }
- }