Skip to Main Content
C# Cookbook, 2nd Edition
book

C# Cookbook, 2nd Edition

by Jay Hilyard, Stephen Teilhet
January 2006
Intermediate to advanced content levelIntermediate to advanced
1184 pages
43h 23m
English
O'Reilly Media, Inc.
Content preview from C# Cookbook, 2nd Edition
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Using the Windows Keyboard Hook
|
529
you could prevent the user from using specific keys (such as the Windows key) from
within your application.
Solution
The Windows Forms application shown in Example 9-13 uses the WH_KEYBOARD Win-
dows hook.
Example 9-13. Using the Windows keyboard hook
using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WindowsApplication2
{
public class Form1 : System.Windows.Forms.Form
{
// Required designer variable
private System.ComponentModel.Container components = null;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.TextBox textBox1;
public Form1( )
{
// Required for Windows Form Designer support
InitializeComponent( );
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose( );
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent( )
{
this.button1 = new System.Windows.Forms.Button( );
this.button2 = new System.Windows.Forms.Button( );
this.textBox1 = new System.Windows.Forms.TextBox( );
This ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

C# Cookbook

C# Cookbook

Stephen Teilhet, Jay Hilyard
C# Cookbook

C# Cookbook

Joe Mayo
Head First C#, 4th Edition

Head First C#, 4th Edition

Andrew Stellman, Jennifer Greene

Publisher Resources

ISBN: 0596100639Supplemental ContentCatalog PageErrata