473,608 Members | 2,667 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Handling Keyboard Shortcuts

BD
How can I duplicate the behavior of the operating system shortcut keys
in my application? For example, my windows form has 5 controls
(textboxes), the operating system will pickup which control has the
focus and handle ctrl-c, ctrl-v, or any other shortcuts. I have the
same shortcuts working in my app, but have not determined how to find
out which control has focus. Would I set up a loop or code for each
control at form level. Any help is greatly appreciated.

BD
Jun 27 '08 #1
8 5289
On Mon, 21 Apr 2008 13:41:19 -0700, BD <bw******@chart er.netwrote:
How can I duplicate the behavior of the operating system shortcut keys
in my application? For example, my windows form has 5 controls
(textboxes), the operating system will pickup which control has the
focus and handle ctrl-c, ctrl-v, or any other shortcuts. I have the
same shortcuts working in my app, but have not determined how to find
out which control has focus.
I'm not sure you really understand how keyboard input happens. The OS
isn't doing anything special for control-modified keys. All it does is
make sure that the keyboard input is sent to whatever window has the
current focus, and that window deals with it.

In the case of .NET, each instance of Control has its own window, and when
the Control has focus, that means its window has focus and is receiving
keyboard input. Then it's simply a matter of the Control handling the
input as appropriate.

If you want your own custom control to handle keyboard input, you need to
make sure that your control can receive focus, and is handling the
keyboard input messages. Once you've done that, then if and when your
control actually has the focus, it will automatically receive the keyboard
input, which you can then inspect, looking for special key input such as
Ctrl-C, Ctrl-V, etc.

At no point should you need to worry about which control actually has the
focus. Assuming you've implemented your control properly, it will receive
keyboard input appropriately when it has focus, without any additional
effort from you.

Note that for your control to receive focus, its CanFocus property needs
to return "true" (i.e. set the ControlStyle.Se lectable flag with the
SetStyle() method). You should also make sure that your control has some
visible representation that indicates when it has focus, which of course
means handling the focus events (e.g. override OnGotFocus(),
OnLostFocus()) so that you know when your state changes.

Pete
Jun 27 '08 #2
BD
On Apr 21, 4:17 pm, "Peter Duniho" <NpOeStPe...@nn owslpianmk.com>
wrote:
On Mon, 21 Apr 2008 13:41:19 -0700, BD <bwald...@chart er.netwrote:
How can I duplicate the behavior of the operating system shortcut keys
in my application? For example, my windows form has 5 controls
(textboxes), the operating system will pickup which control has the
focus and handle ctrl-c, ctrl-v, or any other shortcuts. I have the
same shortcuts working in my app, but have not determined how to find
out which control has focus.

I'm not sure you really understand how keyboard input happens. The OS
isn't doing anything special for control-modified keys. All it does is
make sure that the keyboard input is sent to whatever window has the
current focus, and that window deals with it.

In the case of .NET, each instance of Control has its own window, and when
the Control has focus, that means its window has focus and is receiving
keyboard input. Then it's simply a matter of the Control handling the
input as appropriate.

If you want your own custom control to handle keyboard input, you need to
make sure that your control can receive focus, and is handling the
keyboard input messages. Once you've done that, then if and when your
control actually has the focus, it will automatically receive the keyboard
input, which you can then inspect, looking for special key input such as
Ctrl-C, Ctrl-V, etc.

At no point should you need to worry about which control actually has the
focus. Assuming you've implemented your control properly, it will receive
keyboard input appropriately when it has focus, without any additional
effort from you.

Note that for your control to receive focus, its CanFocus property needs
to return "true" (i.e. set the ControlStyle.Se lectable flag with the
SetStyle() method). You should also make sure that your control has some
visible representation that indicates when it has focus, which of course
means handling the focus events (e.g. override OnGotFocus(),
OnLostFocus()) so that you know when your state changes.

Pete
I do agree, I may not understand how keyboard input works, I have only
been learning programming for about the past two years on my own. I
perhaps didn't state my issue correctly. The form does use the
shortcuts but with a twist. This is why I posted the way I did. If
my form has the EDIT menu that has the general items inserted, 'ctrl-
v' will not work. However, if you do 'ctrl-shift-v' the program will
paste from the clipboard. If I remove the EDIT menu, 'ctrl-v' or any
of the other shortcuts will work correctly. That is why I thought the
OS was controlling the shortcut. I have looked on the net for some
time to find an answer or even an example of what I see and have come
up empty. I did try protected override bool ProcessCmdKey(r ef Message
msg, Keys keyData), which will make the shortcuts work properly, but I
have to identify which textbox to process. That is why I thought I
needed to find out which control has the focus. Again, thanks for the
fast response to my question and I hope to hear from you about my
follow-up.

BD
Jun 27 '08 #3
On Mon, 21 Apr 2008 16:27:26 -0700, BD <bw******@chart er.netwrote:
[...] If
my form has the EDIT menu that has the general items inserted, 'ctrl-
v' will not work. However, if you do 'ctrl-shift-v' the program will
paste from the clipboard. If I remove the EDIT menu, 'ctrl-v' or any
of the other shortcuts will work correctly. That is why I thought the
OS was controlling the shortcut.
I guess that depends on your definition of "OS". Based on your
description, it's possible that .NET is somehow treating your "EDIT" menu
as something special. One thing you might want to try is making sure that
the menu has the usual shortcut keys assigned to each item in the menu.

Beyond that, you will probably need to post a concise-but-complete code
sample that reliably demonstrates the problem. You can describe the issue
in plain English until you're blue in the face, but doing so will never
provide nearly as precise or accurate a description of the problem as an
actual working code sample.

Pete
Jun 27 '08 #4
BD
On Apr 21, 8:38 pm, "Peter Duniho" <NpOeStPe...@nn owslpianmk.com>
wrote:
On Mon, 21 Apr 2008 16:27:26 -0700, BD <bwald...@chart er.netwrote:
[...] If
my form has the EDIT menu that has the general items inserted, 'ctrl-
v' will not work. However, if you do 'ctrl-shift-v' the program will
paste from the clipboard. If I remove the EDIT menu, 'ctrl-v' or any
of the other shortcuts will work correctly. That is why I thought the
OS was controlling the shortcut.

I guess that depends on your definition of "OS". Based on your
description, it's possible that .NET is somehow treating your "EDIT" menu
as something special. One thing you might want to try is making sure that
the menu has the usual shortcut keys assigned to each item in the menu.

Beyond that, you will probably need to post a concise-but-complete code
sample that reliably demonstrates the problem. You can describe the issue
in plain English until you're blue in the face, but doing so will never
provide nearly as precise or accurate a description of the problem as an
actual working code sample.

Pete
The app I am sending is a testing app that I created for control
testing. I just created it the other day. It has two forms, one form
to tell me the ASCII numbers of the keys I am pressing the main form
which is form1. Form1 is very simple with only two textboxes and two
labels. Textbox1 is a multi-line textbox. I used the standard menu
inserted by Visual Studio 2005 (file, edit, tools, help). The
following is the code I have from Form1.cs:

using System;
using System.Collecti ons.Generic;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows. Forms;

namespace TestingApplicat ion
{
public partial class Form1 : Form
{
public Form1()
{
InitializeCompo nent();
}

protected override bool ProcessCmdKey(r ef Message msg, Keys
keyData)
{
const int WM_KEYDOWN = 0x100;
const int WM_SYSKEYDOWN = 0x104;

if ((msg.Msg == WM_KEYDOWN) || (msg.Msg == WM_SYSKEYDOWN))
{
switch (keyData)
{
case (Keys.V | Keys.Control):
textBox1.Text = Clipboard.GetTe xt();
return true;
break;

case (Keys.C | Keys.Control):
if (textBox1.Selec tedText != "")

Clipboard.SetDa taObject(textBo x1.SelectedText );
else
MessageBox.Show ("There is no data to copy
to the clipboard.");
return true;
break;
}
}
return base.ProcessCmd Key(ref msg, keyData);
}

private void undoToolStripMe nuItem_Click(ob ject sender,
EventArgs e)
{
textBox1.Undo() ;
}

private void selectAllToolSt ripMenuItem_Cli ck(object sender,
EventArgs e)
{
textBox1.Select ionStart = 0;
textBox1.Select ionLength = textBox1.TextLe ngth;
}

private void editToolStripMe nuItem_Click(ob ject sender,
EventArgs e)
{
if (textBox1.Selec tionLength == 0)
{
cutToolStripMen uItem.Enabled = false;
copyToolStripMe nuItem.Enabled = false;
}
}

private void button1_Click(o bject sender, EventArgs e)
{
KeyCode frm = new KeyCode();
frm.Show();
frm.Focus();
}

If the designer code is needed, I will send it as well. Again, when
the 'edit' menu is there, shortcut keys for copy and paste for example
require the key combination 'ctrl+shift+c' or 'ctrl+shift+v'.
However, if the edit menu is removed, 'ctrl+c' or 'ctrl+v' work as
they are should.

BD
Jun 27 '08 #5
On Tue, 22 Apr 2008 05:17:33 -0700, BD <bw******@chart er.netwrote:
[...]
If the designer code is needed, I will send it as well. Again, when
the 'edit' menu is there, shortcut keys for copy and paste for example
require the key combination 'ctrl+shift+c' or 'ctrl+shift+v'.
However, if the edit menu is removed, 'ctrl+c' or 'ctrl+v' work as
they are should.
Inasmuch as your question seems to be specifically related to the exact
configuration of the menus, you should either create the menus
programmaticall y in the Form1 class, or you should post the complete
Designer code for the test application.

Pete
Jun 27 '08 #6
BD
On Apr 22, 1:47 pm, "Peter Duniho" <NpOeStPe...@nn owslpianmk.com>
wrote:
On Tue, 22 Apr 2008 05:17:33 -0700, BD <bwald...@chart er.netwrote:
[...]
If the designer code is needed, I will send it as well. Again, when
the 'edit' menu is there, shortcut keys for copy and paste for example
require the key combination 'ctrl+shift+c' or 'ctrl+shift+v'.
However, if the edit menu is removed, 'ctrl+c' or 'ctrl+v' work as
they are should.

Inasmuch as your question seems to be specifically related to the exact
configuration of the menus, you should either create the menus
programmaticall y in the Form1 class, or you should post the complete
Designer code for the test application.

Pete
Here is the designer code:
namespace TestingApplicat ion
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.Componen tModel.IContain er components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing ">true if managed resources should
be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Disp ose();
}
base.Dispose(di sposing);
}

#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 InitializeCompo nent()
{
System.Componen tModel.Componen tResourceManage r resources =
new System.Componen tModel.Componen tResourceManage r(typeof(Form1) );
this.label1 = new System.Windows. Forms.Label();
this.label2 = new System.Windows. Forms.Label();
this.label3 = new System.Windows. Forms.Label();
this.label4 = new System.Windows. Forms.Label();
this.label5 = new System.Windows. Forms.Label();
this.textBox1 = new System.Windows. Forms.TextBox() ;
this.textBox2 = new System.Windows. Forms.TextBox() ;
this.statusStri p1 = new
System.Windows. Forms.StatusStr ip();
this.toolStripS tatusLabel1 = new
System.Windows. Forms.ToolStrip StatusLabel();
this.toolStripP rogressBar1 = new
System.Windows. Forms.ToolStrip ProgressBar();
this.fileToolSt ripMenuItem = new
System.Windows. Forms.ToolStrip MenuItem();
this.newToolStr ipMenuItem = new
System.Windows. Forms.ToolStrip MenuItem();
this.openToolSt ripMenuItem = new
System.Windows. Forms.ToolStrip MenuItem();
this.toolStripS eparator = new
System.Windows. Forms.ToolStrip Separator();
this.saveToolSt ripMenuItem = new
System.Windows. Forms.ToolStrip MenuItem();
this.saveAsTool StripMenuItem = new
System.Windows. Forms.ToolStrip MenuItem();
this.toolStripS eparator1 = new
System.Windows. Forms.ToolStrip Separator();
this.printToolS tripMenuItem = new
System.Windows. Forms.ToolStrip MenuItem();
this.printPrevi ewToolStripMenu Item = new
System.Windows. Forms.ToolStrip MenuItem();
this.toolStripS eparator2 = new
System.Windows. Forms.ToolStrip Separator();
this.exitToolSt ripMenuItem = new
System.Windows. Forms.ToolStrip MenuItem();
this.toolsToolS tripMenuItem = new
System.Windows. Forms.ToolStrip MenuItem();
this.customizeT oolStripMenuIte m = new
System.Windows. Forms.ToolStrip MenuItem();
this.optionsToo lStripMenuItem = new
System.Windows. Forms.ToolStrip MenuItem();
this.helpToolSt ripMenuItem = new
System.Windows. Forms.ToolStrip MenuItem();
this.contentsTo olStripMenuItem = new
System.Windows. Forms.ToolStrip MenuItem();
this.indexToolS tripMenuItem = new
System.Windows. Forms.ToolStrip MenuItem();
this.searchTool StripMenuItem = new
System.Windows. Forms.ToolStrip MenuItem();
this.toolStripS eparator5 = new
System.Windows. Forms.ToolStrip Separator();
this.aboutToolS tripMenuItem = new
System.Windows. Forms.ToolStrip MenuItem();
this.menuStrip1 = new System.Windows. Forms.MenuStrip ();
this.editToolSt ripMenuItem = new
System.Windows. Forms.ToolStrip MenuItem();
this.undoToolSt ripMenuItem = new
System.Windows. Forms.ToolStrip MenuItem();
this.redoToolSt ripMenuItem = new
System.Windows. Forms.ToolStrip MenuItem();
this.toolStripS eparator3 = new
System.Windows. Forms.ToolStrip Separator();
this.cutToolStr ipMenuItem = new
System.Windows. Forms.ToolStrip MenuItem();
this.copyToolSt ripMenuItem = new
System.Windows. Forms.ToolStrip MenuItem();
this.pasteToolS tripMenuItem = new
System.Windows. Forms.ToolStrip MenuItem();
this.toolStripS eparator4 = new
System.Windows. Forms.ToolStrip Separator();
this.selectAllT oolStripMenuIte m = new
System.Windows. Forms.ToolStrip MenuItem();
this.button1 = new System.Windows. Forms.Button();
this.statusStri p1.SuspendLayou t();
this.menuStrip1 .SuspendLayout( );
this.SuspendLay out();
//
// label1
//
this.label1.Aut oSize = true;
this.label1.Loc ation = new System.Drawing. Point(16, 36);
this.label1.Nam e = "label1";
this.label1.Siz e = new System.Drawing. Size(66, 13);
this.label1.Tab Index = 1;
this.label1.Tex t = "Sample Text";
//
// label2
//
this.label2.Aut oSize = true;
this.label2.Loc ation = new System.Drawing. Point(16, 196);
this.label2.Nam e = "label2";
this.label2.Siz e = new System.Drawing. Size(35, 13);
this.label2.Tab Index = 2;
this.label2.Tex t = "label2";
//
// label3
//
this.label3.Aut oSize = true;
this.label3.Loc ation = new System.Drawing. Point(16, 262);
this.label3.Nam e = "label3";
this.label3.Siz e = new System.Drawing. Size(35, 13);
this.label3.Tab Index = 3;
this.label3.Tex t = "label3";
//
// label4
//
this.label4.Aut oSize = true;
this.label4.Loc ation = new System.Drawing. Point(16, 302);
this.label4.Nam e = "label4";
this.label4.Siz e = new System.Drawing. Size(35, 13);
this.label4.Tab Index = 4;
this.label4.Tex t = "label4";
//
// label5
//
this.label5.Aut oSize = true;
this.label5.Loc ation = new System.Drawing. Point(16, 347);
this.label5.Nam e = "label5";
this.label5.Siz e = new System.Drawing. Size(35, 13);
this.label5.Tab Index = 5;
this.label5.Tex t = "label5";
//
// textBox1
//
this.textBox1.L ocation = new System.Drawing. Point(88, 36);
this.textBox1.M ultiline = true;
this.textBox1.N ame = "textBox1";
this.textBox1.S ize = new System.Drawing. Size(341, 146);
this.textBox1.T abIndex = 6;
this.textBox1.K eyDown += new
System.Windows. Forms.KeyEventH andler(this.tex tBox1_KeyDown);
this.textBox1.K eyPress += new
System.Windows. Forms.KeyPressE ventHandler(thi s.textBox1_KeyP ress);
//
// textBox2
//
this.textBox2.L ocation = new System.Drawing. Point(88,
193);
this.textBox2.N ame = "textBox2";
this.textBox2.S ize = new System.Drawing. Size(100, 20);
this.textBox2.T abIndex = 7;
//
// statusStrip1
//
this.statusStri p1.Items.AddRan ge(new
System.Windows. Forms.ToolStrip Item[] {
this.toolStripS tatusLabel1,
this.toolStripP rogressBar1});
this.statusStri p1.Location = new System.Drawing. Point(0,
414);
this.statusStri p1.Name = "statusStri p1";
this.statusStri p1.Size = new System.Drawing. Size(855, 22);
this.statusStri p1.TabIndex = 8;
this.statusStri p1.Text = "statusStri p1";
//
// toolStripStatus Label1
//
this.toolStripS tatusLabel1.Nam e = "toolStripStatu sLabel1";
this.toolStripS tatusLabel1.Siz e = new
System.Drawing. Size(740, 17);
this.toolStripS tatusLabel1.Spr ing = true;
this.toolStripS tatusLabel1.Tex t = "toolStripStatu sLabel1";
//
// toolStripProgre ssBar1
//
this.toolStripP rogressBar1.Nam e = "toolStripProgr essBar1";
this.toolStripP rogressBar1.Siz e = new
System.Drawing. Size(100, 16);
//
// fileToolStripMe nuItem
//
this.fileToolSt ripMenuItem.Dro pDownItems.AddR ange(new
System.Windows. Forms.ToolStrip Item[] {
this.newToolStr ipMenuItem,
this.openToolSt ripMenuItem,
this.toolStripS eparator,
this.saveToolSt ripMenuItem,
this.saveAsTool StripMenuItem,
this.toolStripS eparator1,
this.printToolS tripMenuItem,
this.printPrevi ewToolStripMenu Item,
this.toolStripS eparator2,
this.exitToolSt ripMenuItem});
this.fileToolSt ripMenuItem.Nam e = "fileToolStripM enuItem";
this.fileToolSt ripMenuItem.Siz e = new
System.Drawing. Size(35, 20);
this.fileToolSt ripMenuItem.Tex t = "&File";
//
// newToolStripMen uItem
//
this.newToolStr ipMenuItem.Imag e = ((System.Drawin g.Image)
(resources.GetO bject("newToolS tripMenuItem.Im age")));
this.newToolStr ipMenuItem.Imag eTransparentCol or =
System.Drawing. Color.Magenta;
this.newToolStr ipMenuItem.Name = "newToolStripMe nuItem";
this.newToolStr ipMenuItem.Shor tcutKeys =
((System.Window s.Forms.Keys)(( System.Windows. Forms.Keys.Cont rol |
System.Windows. Forms.Keys.N))) ;
this.newToolStr ipMenuItem.Size = new
System.Drawing. Size(151, 22);
this.newToolStr ipMenuItem.Text = "&New";
//
// openToolStripMe nuItem
//
this.openToolSt ripMenuItem.Ima ge = ((System.Drawin g.Image)
(resources.GetO bject("openTool StripMenuItem.I mage")));
this.openToolSt ripMenuItem.Ima geTransparentCo lor =
System.Drawing. Color.Magenta;
this.openToolSt ripMenuItem.Nam e = "openToolStripM enuItem";
this.openToolSt ripMenuItem.Sho rtcutKeys =
((System.Window s.Forms.Keys)(( System.Windows. Forms.Keys.Cont rol |
System.Windows. Forms.Keys.O))) ;
this.openToolSt ripMenuItem.Siz e = new
System.Drawing. Size(151, 22);
this.openToolSt ripMenuItem.Tex t = "&Open";
//
// toolStripSepara tor
//
this.toolStripS eparator.Name = "toolStripSepar ator";
this.toolStripS eparator.Size = new
System.Drawing. Size(148, 6);
//
// saveToolStripMe nuItem
//
this.saveToolSt ripMenuItem.Ima ge = ((System.Drawin g.Image)
(resources.GetO bject("saveTool StripMenuItem.I mage")));
this.saveToolSt ripMenuItem.Ima geTransparentCo lor =
System.Drawing. Color.Magenta;
this.saveToolSt ripMenuItem.Nam e = "saveToolStripM enuItem";
this.saveToolSt ripMenuItem.Sho rtcutKeys =
((System.Window s.Forms.Keys)(( System.Windows. Forms.Keys.Cont rol |
System.Windows. Forms.Keys.S))) ;
this.saveToolSt ripMenuItem.Siz e = new
System.Drawing. Size(151, 22);
this.saveToolSt ripMenuItem.Tex t = "&Save";
//
// saveAsToolStrip MenuItem
//
this.saveAsTool StripMenuItem.N ame =
"saveAsToolStri pMenuItem";
this.saveAsTool StripMenuItem.S ize = new
System.Drawing. Size(151, 22);
this.saveAsTool StripMenuItem.T ext = "Save &As";
//
// toolStripSepara tor1
//
this.toolStripS eparator1.Name = "toolStripSepar ator1";
this.toolStripS eparator1.Size = new
System.Drawing. Size(148, 6);
//
// printToolStripM enuItem
//
this.printToolS tripMenuItem.Im age = ((System.Drawin g.Image)
(resources.GetO bject("printToo lStripMenuItem. Image")));
this.printToolS tripMenuItem.Im ageTransparentC olor =
System.Drawing. Color.Magenta;
this.printToolS tripMenuItem.Na me =
"printToolStrip MenuItem";
this.printToolS tripMenuItem.Sh ortcutKeys =
((System.Window s.Forms.Keys)(( System.Windows. Forms.Keys.Cont rol |
System.Windows. Forms.Keys.P))) ;
this.printToolS tripMenuItem.Si ze = new
System.Drawing. Size(151, 22);
this.printToolS tripMenuItem.Te xt = "&Print";
//
// printPreviewToo lStripMenuItem
//
this.printPrevi ewToolStripMenu Item.Image =
((System.Drawin g.Image)
(resources.GetO bject("printPre viewToolStripMe nuItem.Image")) );
this.printPrevi ewToolStripMenu Item.ImageTrans parentColor =
System.Drawing. Color.Magenta;
this.printPrevi ewToolStripMenu Item.Name =
"printPreviewTo olStripMenuItem ";
this.printPrevi ewToolStripMenu Item.Size = new
System.Drawing. Size(151, 22);
this.printPrevi ewToolStripMenu Item.Text = "Print
Pre&view";
//
// toolStripSepara tor2
//
this.toolStripS eparator2.Name = "toolStripSepar ator2";
this.toolStripS eparator2.Size = new
System.Drawing. Size(148, 6);
//
// exitToolStripMe nuItem
//
this.exitToolSt ripMenuItem.Nam e = "exitToolStripM enuItem";
this.exitToolSt ripMenuItem.Siz e = new
System.Drawing. Size(151, 22);
this.exitToolSt ripMenuItem.Tex t = "E&xit";
//
// toolsToolStripM enuItem
//
this.toolsToolS tripMenuItem.Dr opDownItems.Add Range(new
System.Windows. Forms.ToolStrip Item[] {
this.customizeT oolStripMenuIte m,
this.optionsToo lStripMenuItem} );
this.toolsToolS tripMenuItem.Na me =
"toolsToolStrip MenuItem";
this.toolsToolS tripMenuItem.Si ze = new
System.Drawing. Size(44, 20);
this.toolsToolS tripMenuItem.Te xt = "&Tools";
//
// customizeToolSt ripMenuItem
//
this.customizeT oolStripMenuIte m.Name =
"customizeToolS tripMenuItem";
this.customizeT oolStripMenuIte m.Size = new
System.Drawing. Size(134, 22);
this.customizeT oolStripMenuIte m.Text = "&Customize ";
//
// optionsToolStri pMenuItem
//
this.optionsToo lStripMenuItem. Name =
"optionsToolStr ipMenuItem";
this.optionsToo lStripMenuItem. Size = new
System.Drawing. Size(134, 22);
this.optionsToo lStripMenuItem. Text = "&Options";
//
// helpToolStripMe nuItem
//
this.helpToolSt ripMenuItem.Dro pDownItems.AddR ange(new
System.Windows. Forms.ToolStrip Item[] {
this.contentsTo olStripMenuItem ,
this.indexToolS tripMenuItem,
this.searchTool StripMenuItem,
this.toolStripS eparator5,
this.aboutToolS tripMenuItem});
this.helpToolSt ripMenuItem.Nam e = "helpToolStripM enuItem";
this.helpToolSt ripMenuItem.Siz e = new
System.Drawing. Size(40, 20);
this.helpToolSt ripMenuItem.Tex t = "&Help";
//
// contentsToolStr ipMenuItem
//
this.contentsTo olStripMenuItem .Name =
"contentsToolSt ripMenuItem";
this.contentsTo olStripMenuItem .Size = new
System.Drawing. Size(129, 22);
this.contentsTo olStripMenuItem .Text = "&Contents" ;
//
// indexToolStripM enuItem
//
this.indexToolS tripMenuItem.Na me =
"indexToolStrip MenuItem";
this.indexToolS tripMenuItem.Si ze = new
System.Drawing. Size(129, 22);
this.indexToolS tripMenuItem.Te xt = "&Index";
//
// searchToolStrip MenuItem
//
this.searchTool StripMenuItem.N ame =
"searchToolStri pMenuItem";
this.searchTool StripMenuItem.S ize = new
System.Drawing. Size(129, 22);
this.searchTool StripMenuItem.T ext = "&Search";
//
// toolStripSepara tor5
//
this.toolStripS eparator5.Name = "toolStripSepar ator5";
this.toolStripS eparator5.Size = new
System.Drawing. Size(126, 6);
//
// aboutToolStripM enuItem
//
this.aboutToolS tripMenuItem.Na me =
"aboutToolStrip MenuItem";
this.aboutToolS tripMenuItem.Si ze = new
System.Drawing. Size(129, 22);
this.aboutToolS tripMenuItem.Te xt = "&About..." ;
//
// menuStrip1
//
this.menuStrip1 .Items.AddRange (new
System.Windows. Forms.ToolStrip Item[] {
this.fileToolSt ripMenuItem,
this.editToolSt ripMenuItem,
this.toolsToolS tripMenuItem,
this.helpToolSt ripMenuItem});
this.menuStrip1 .Location = new System.Drawing. Point(0, 0);
this.menuStrip1 .Name = "menuStrip1 ";
this.menuStrip1 .Size = new System.Drawing. Size(855, 24);
this.menuStrip1 .TabIndex = 0;
this.menuStrip1 .Text = "menuStrip1 ";
//
// editToolStripMe nuItem
//
this.editToolSt ripMenuItem.Dro pDownItems.AddR ange(new
System.Windows. Forms.ToolStrip Item[] {
this.undoToolSt ripMenuItem,
this.redoToolSt ripMenuItem,
this.toolStripS eparator3,
this.cutToolStr ipMenuItem,
this.copyToolSt ripMenuItem,
this.pasteToolS tripMenuItem,
this.toolStripS eparator4,
this.selectAllT oolStripMenuIte m});
this.editToolSt ripMenuItem.Nam e = "editToolStripM enuItem";
this.editToolSt ripMenuItem.Siz e = new
System.Drawing. Size(37, 20);
this.editToolSt ripMenuItem.Tex t = "&Edit";
this.editToolSt ripMenuItem.Cli ck += new
System.EventHan dler(this.editT oolStripMenuIte m_Click);
//
// undoToolStripMe nuItem
//
this.undoToolSt ripMenuItem.Nam e = "undoToolStripM enuItem";
this.undoToolSt ripMenuItem.Sho rtcutKeys =
((System.Window s.Forms.Keys)(( System.Windows. Forms.Keys.Cont rol |
System.Windows. Forms.Keys.Z))) ;
this.undoToolSt ripMenuItem.Siz e = new
System.Drawing. Size(150, 22);
this.undoToolSt ripMenuItem.Tex t = "&Undo";
this.undoToolSt ripMenuItem.Cli ck += new
System.EventHan dler(this.undoT oolStripMenuIte m_Click);
//
// redoToolStripMe nuItem
//
this.redoToolSt ripMenuItem.Nam e = "redoToolStripM enuItem";
this.redoToolSt ripMenuItem.Sho rtcutKeys =
((System.Window s.Forms.Keys)(( System.Windows. Forms.Keys.Cont rol |
System.Windows. Forms.Keys.Y))) ;
this.redoToolSt ripMenuItem.Siz e = new
System.Drawing. Size(150, 22);
this.redoToolSt ripMenuItem.Tex t = "&Redo";
//
// toolStripSepara tor3
//
this.toolStripS eparator3.Name = "toolStripSepar ator3";
this.toolStripS eparator3.Size = new
System.Drawing. Size(147, 6);
//
// cutToolStripMen uItem
//
this.cutToolStr ipMenuItem.Imag e = ((System.Drawin g.Image)
(resources.GetO bject("cutToolS tripMenuItem.Im age")));
this.cutToolStr ipMenuItem.Imag eTransparentCol or =
System.Drawing. Color.Magenta;
this.cutToolStr ipMenuItem.Name = "cutToolStripMe nuItem";
this.cutToolStr ipMenuItem.Shor tcutKeys =
((System.Window s.Forms.Keys)(( System.Windows. Forms.Keys.Cont rol |
System.Windows. Forms.Keys.X))) ;
this.cutToolStr ipMenuItem.Size = new
System.Drawing. Size(150, 22);
this.cutToolStr ipMenuItem.Text = "Cu&t";
//
// copyToolStripMe nuItem
//
this.copyToolSt ripMenuItem.Ima ge = ((System.Drawin g.Image)
(resources.GetO bject("copyTool StripMenuItem.I mage")));
this.copyToolSt ripMenuItem.Ima geTransparentCo lor =
System.Drawing. Color.Magenta;
this.copyToolSt ripMenuItem.Nam e = "copyToolStripM enuItem";
this.copyToolSt ripMenuItem.Sho rtcutKeys =
((System.Window s.Forms.Keys)(( System.Windows. Forms.Keys.Cont rol |
System.Windows. Forms.Keys.C))) ;
this.copyToolSt ripMenuItem.Siz e = new
System.Drawing. Size(167, 22);
this.copyToolSt ripMenuItem.Tex t = "&Copy";
this.copyToolSt ripMenuItem.Cli ck += new
System.EventHan dler(this.copyT oolStripMenuIte m_Click);
//
// pasteToolStripM enuItem
//
this.pasteToolS tripMenuItem.Im age = ((System.Drawin g.Image)
(resources.GetO bject("pasteToo lStripMenuItem. Image")));
this.pasteToolS tripMenuItem.Im ageTransparentC olor =
System.Drawing. Color.Magenta;
this.pasteToolS tripMenuItem.Na me =
"pasteToolStrip MenuItem";
this.pasteToolS tripMenuItem.Sh ortcutKeys =
((System.Window s.Forms.Keys)(( System.Windows. Forms.Keys.Cont rol |
System.Windows. Forms.Keys.V))) ;
this.pasteToolS tripMenuItem.Si ze = new
System.Drawing. Size(150, 22);
this.pasteToolS tripMenuItem.Te xt = "&Paste";
//
// toolStripSepara tor4
//
this.toolStripS eparator4.Name = "toolStripSepar ator4";
this.toolStripS eparator4.Size = new
System.Drawing. Size(147, 6);
//
// selectAllToolSt ripMenuItem
//
this.selectAllT oolStripMenuIte m.Name =
"selectAllToolS tripMenuItem";
this.selectAllT oolStripMenuIte m.ShortcutKeys =
((System.Window s.Forms.Keys)(( System.Windows. Forms.Keys.Cont rol |
System.Windows. Forms.Keys.A))) ;
this.selectAllT oolStripMenuIte m.Size = new
System.Drawing. Size(167, 22);
this.selectAllT oolStripMenuIte m.Text = "Select &All";
this.selectAllT oolStripMenuIte m.Click += new
System.EventHan dler(this.selec tAllToolStripMe nuItem_Click);
//
// button1
//
this.button1.Lo cation = new System.Drawing. Point(590,
287);
this.button1.Na me = "button1";
this.button1.Si ze = new System.Drawing. Size(152, 23);
this.button1.Ta bIndex = 9;
this.button1.Te xt = "Key Code Info Form";
this.button1.Us eVisualStyleBac kColor = true;
this.button1.Cl ick += new
System.EventHan dler(this.butto n1_Click);
//
// Form1
//
this.AutoScaleD imensions = new System.Drawing. SizeF(6F,
13F);
this.AutoScaleM ode =
System.Windows. Forms.AutoScale Mode.Font;
this.ClientSize = new System.Drawing. Size(855, 436);
this.Controls.A dd(this.button1 );
this.Controls.A dd(this.statusS trip1);
this.Controls.A dd(this.textBox 2);
this.Controls.A dd(this.textBox 1);
this.Controls.A dd(this.label5) ;
this.Controls.A dd(this.label4) ;
this.Controls.A dd(this.label3) ;
this.Controls.A dd(this.label2) ;
this.Controls.A dd(this.label1) ;
this.Controls.A dd(this.menuStr ip1);
this.MainMenuSt rip = this.menuStrip1 ;
this.Name = "Form1";
this.Text = "Form1";
this.KeyPress += new
System.Windows. Forms.KeyPressE ventHandler(thi s.Form1_KeyPres s);
this.KeyDown += new
System.Windows. Forms.KeyEventH andler(this.For m1_KeyDown);
this.statusStri p1.ResumeLayout (false);
this.statusStri p1.PerformLayou t();
this.menuStrip1 .ResumeLayout(f alse);
this.menuStrip1 .PerformLayout( );
this.ResumeLayo ut(false);
this.PerformLay out();

}

#endregion

private System.Windows. Forms.Label label1;
private System.Windows. Forms.Label label2;
private System.Windows. Forms.Label label3;
private System.Windows. Forms.Label label4;
private System.Windows. Forms.Label label5;
private System.Windows. Forms.TextBox textBox1;
private System.Windows. Forms.TextBox textBox2;
private System.Windows. Forms.StatusStr ip statusStrip1;
private System.Windows. Forms.ToolStrip StatusLabel
toolStripStatus Label1;
private System.Windows. Forms.ToolStrip ProgressBar
toolStripProgre ssBar1;
private System.Windows. Forms.ToolStrip MenuItem
fileToolStripMe nuItem;
private System.Windows. Forms.ToolStrip MenuItem
newToolStripMen uItem;
private System.Windows. Forms.ToolStrip MenuItem
openToolStripMe nuItem;
private System.Windows. Forms.ToolStrip Separator
toolStripSepara tor;
private System.Windows. Forms.ToolStrip MenuItem
saveToolStripMe nuItem;
private System.Windows. Forms.ToolStrip MenuItem
saveAsToolStrip MenuItem;
private System.Windows. Forms.ToolStrip Separator
toolStripSepara tor1;
private System.Windows. Forms.ToolStrip MenuItem
printToolStripM enuItem;
private System.Windows. Forms.ToolStrip MenuItem
printPreviewToo lStripMenuItem;
private System.Windows. Forms.ToolStrip Separator
toolStripSepara tor2;
private System.Windows. Forms.ToolStrip MenuItem
exitToolStripMe nuItem;
private System.Windows. Forms.ToolStrip MenuItem
toolsToolStripM enuItem;
private System.Windows. Forms.ToolStrip MenuItem
customizeToolSt ripMenuItem;
private System.Windows. Forms.ToolStrip MenuItem
optionsToolStri pMenuItem;
private System.Windows. Forms.ToolStrip MenuItem
helpToolStripMe nuItem;
private System.Windows. Forms.ToolStrip MenuItem
contentsToolStr ipMenuItem;
private System.Windows. Forms.ToolStrip MenuItem
indexToolStripM enuItem;
private System.Windows. Forms.ToolStrip MenuItem
searchToolStrip MenuItem;
private System.Windows. Forms.ToolStrip Separator
toolStripSepara tor5;
private System.Windows. Forms.ToolStrip MenuItem
aboutToolStripM enuItem;
private System.Windows. Forms.MenuStrip menuStrip1;
private System.Windows. Forms.ToolStrip MenuItem
editToolStripMe nuItem;
private System.Windows. Forms.ToolStrip MenuItem
undoToolStripMe nuItem;
private System.Windows. Forms.ToolStrip MenuItem
redoToolStripMe nuItem;
private System.Windows. Forms.ToolStrip Separator
toolStripSepara tor3;
private System.Windows. Forms.ToolStrip MenuItem
cutToolStripMen uItem;
private System.Windows. Forms.ToolStrip MenuItem
copyToolStripMe nuItem;
private System.Windows. Forms.ToolStrip MenuItem
pasteToolStripM enuItem;
private System.Windows. Forms.ToolStrip Separator
toolStripSepara tor4;
private System.Windows. Forms.ToolStrip MenuItem
selectAllToolSt ripMenuItem;
private System.Windows. Forms.Button button1;
}
}

Jun 27 '08 #7
On Tue, 22 Apr 2008 12:58:40 -0700, BD <bw******@chart er.netwrote:
Here is the designer code: [...]
Okay. Now post a _concise_ version. Include absolutely _nothing_ that is
not fundamentally required to demonstrate the issue.

If you're having trouble understanding what I mean, or why this is
important, you may find Jon Skeet's article on the topic useful:
http://www.skeet.org.uk/csharp/complete.html

Pete
Jun 27 '08 #8
BD
On Apr 22, 4:56 pm, "Peter Duniho" <NpOeStPe...@nn owslpianmk.com>
wrote:
On Tue, 22 Apr 2008 12:58:40 -0700, BD <bwald...@chart er.netwrote:
Here is the designer code: [...]

Okay. Now post a _concise_ version. Include absolutely _nothing_ that is
not fundamentally required to demonstrate the issue.

If you're having trouble understanding what I mean, or why this is
important, you may find Jon Skeet's article on the topic useful: http://www.skeet.org.uk/csharp/complete.html

Pete
Would it be better if I sent a compiled version to your email?
Jun 27 '08 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1788
by: Spartanicus | last post by:
Some use the kbd element (Example: <kbd>Ctrl</kbd>+<kbd>G</kbd>) to mark up keyboard shortcuts, but the spec defines kbd as: "Indicates *text* to be entered by the user." (emphasis mine). UA support aside, what's the best way to do this? -- Spartanicus
0
2514
by: ekta | last post by:
How do we write the code for Keyboard shortcuts in asp.net(c#).Is it possible through javascript only or there is any method/property availaible (like Accesskey) in asp.net. Thanks
5
8616
by: bob lambert | last post by:
Hi, I have a vb .net std 2002 windows form app and wanted to use keyboard shortcuts (& in text property input) It shows up on the design view, but when I build (in debug mode) and display the form for use, the characters that are ampersanded do not show up underlined and the keyboard shortcut does not work ?
4
2342
by: Helene Day | last post by:
Sorry, this could be a newby question... but how do we do the keyboard shortcuts in .NET buttonname.text = "&Click Me" Does not give the short cut Alt-C for the button. Helene
0
1103
by: Mishaev Mark | last post by:
Hi all, How can I disable the standard keyboard shortcuts that are automatically processed by Visio (Ctrl-D for example)? I've tried to use KeyUp event to set "CancelDefault" property to "true", but the event is not fired upon clicking on "HotKeys" combinations.
1
2000
by: Erland | last post by:
Hello, I am using asp.net 2.0 and I want to add keyboard shortcuts to my application just like the shortcuts you see in GMAIL. I was wondering how can I do this in ASP.NET? Scenerio that would like to implement is as follows " User hits ALT-A on hitting ALT-A a server-side event is raised" Is this possible, I mean can a server side event be raised with a keyboard shortcut OR I will have to raise a client side event? I am kind of...
0
1506
by: Zytan | last post by:
I cannot use & to implement a keyboard shortcut on a TabPage like I can on a Button. Is there a way to easily do this? Maybe TabPages aren't supposed to have keyboard shortcuts, but it would be convenient of they did. thanks, Zytan
331
14804
by: Xah Lee | last post by:
http://xahlee.org/emacs/modernization.html ] The Modernization of Emacs ---------------------------------------- THE PROBLEM Emacs is a great editor. It is perhaps the most powerful and most versatile text editor. And, besides text editing, it also serves as a
1
1362
by: Gilbert Tordeur | last post by:
Hello, Context = Web site with VB2008. Is it possible to define keyboard shortcuts on a webpage, to make it possible for the user to "click" on a button or a link, or to set the focus on a control, by using only the keyboard ? How ? Thank you for your help, Gilbert
0
8050
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8472
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8464
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8324
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6805
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6000
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5471
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3954
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
1574
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.