I've found a link which had the same problem and Microsoft
has raised it as a bug.
Here is the link.
http://groups.google.com/groups?hl=e...=UTF-8&oe=UTF-
8&threadm=ueEnOzwdDHA.2320%
40TK2MSFTNGP12.phx.gbl&rnum=2&prev=/groups%3Fq%
3Dprocessmnemonic%26hl%3Den%26lr%3D%26ie%3DUTF-8%26oe%
3DUTF-8%26scoring%3Dd%26selm%3DueEnOzwdDHA.2320%
2540TK2MSFTNGP12.phx.gbl%26rnum%3D2
[color=blue]
>-----Original Message-----
>Hello,
>
>If you copy the source code from this post into seperate
>files as stated, and compile the code.
>
>Now to reproduce run the code in debug.
>1. Press the Client button.
>2. Put the cursor on to the Textbox.
>3. Press Alt-X and you will see nothing happens. Now[/color]
press[color=blue]
>the Exit button and a message box will popup. Press ok.
>4. You will be back on the main screen.
>5. Press the Client button again.
>6. Put the cursor back on the textbox.
>7. Now Press Alt-C. You will see another screen has been
>loaded which is overlayed. Basically it process the code
>for the Client button and did not process the Change
>button.
>8. Now press the Exit button and a message box will[/color]
popup.[color=blue]
>Press ok.
>9. Now tab to the Exit button (this screen should still
>have a texbox control).
>10. Now press Alt-C and you will see the Change button
>code get's triggered.
>
>Basically if you say why the code is written this way,[/color]
the[color=blue]
>reason is to support the following thing.
>a) We need load a form which is modal and the user needs
>to be able to select menus as well from the MDI, where if
>you use ShowDialog() then you cannot do this.
>b) We need to make sure that the user cannot click onto
>the form beneath the loaded form. (Basically replicate[/color]
the[color=blue]
>Modal concept)
>
>So my problem is that the accelaration keys are not been
>processed correctly.
>
>I've included the source code.
>
>MainForm.cs - Code
>
>using System;
>using System.Drawing;
>using System.Collections;
>using System.ComponentModel;
>using System.Windows.Forms;
>
>namespace MyTest
>{
> /// <summary>
> /// Summary description for Main.
> /// </summary>
> public class MainForm : System.Windows.Forms.Form,
>IMyContainer
> {
> /// <summary>
> /// Required designer variable.
> /// </summary>
> private System.ComponentModel.Container
>components = null;
>
> /// <summary>
> /// The main entry point for the
>application.
> /// </summary>
> [STAThread]
> static void Main()
> {
> Application.Run(new MainForm());
> }
>
> public MainForm()
> {
> //
> // Required for Windows Form
>Designer support
> //
> InitializeComponent();
>
> //
> // TODO: Add any constructor code
>after InitializeComponent call
> //
> }
>
> /// <summary>
> /// Clean up any resources being used.
> /// </summary>
> 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()
> {
> //
> // MainForm
> //
> this.AutoScaleBaseSize = new
>System.Drawing.Size(5, 13);
> this.ClientSize = new
>System.Drawing.Size(432, 342);
> this.IsMdiContainer = true;
> this.Name = "MainForm";
> this.Text = "Main";
> this.Load += new
>System.EventHandler(this.MainForm_Load);
>
> }
> #endregion
>
> private void MainForm_Load(object sender,
>System.EventArgs e)
> {
> this.Show();
> Form1 form1=new Form1(this);
> IMyForm myForm=form1 as IMyForm;
> ShowModal(myForm);
> Application.Exit();
> }
>
> public void ShowModal(IMyForm form)
> {
> try
> {
> Form baseForm = form as
>Form;
> //
> baseForm.MdiParent = this;
>
> baseForm.Enabled = true;
>
> baseForm.Show();
> while (form.IsRunning())
> {
>
> Application.DoEvents();
>
> System.Threading.Thread.Sleep(10);
> }
> baseForm.Hide();
> baseForm.MdiParent = null;
> baseForm.Dispose();
> }
> catch(Exception)
> {
> }
> }
> }
>}
>
>Form1.cs - Code
>
>using System;
>using System.Drawing;
>using System.Collections;
>using System.ComponentModel;
>using System.Windows.Forms;
>using System.Data;
>
>namespace MyTest
>{
> /// <summary>
> /// Summary description for Form1.
> /// </summary>
> public class Form1 : System.Windows.Forms.Form,
>IMyForm
> {
> private IMyContainer m_Container=null;
> private System.Windows.Forms.Button
>button1;
> private System.Windows.Forms.Button
>button2;
> /// <summary>
> /// Required designer variable.
> /// </summary>
> private System.ComponentModel.Container
>components = null;
>
> private bool mIsRunning=true;
> public bool IsRunning()
> {
> return mIsRunning;
> }
>
> public Form1(IMyContainer myContainer)
> {
> m_Container=myContainer;
> //
> // Required for Windows Form
>Designer support
> //
> InitializeComponent();
>
> //
> // TODO: Add any constructor code
>after InitializeComponent call
> //
> }
>
> /// <summary>
> /// Clean up any resources being used.
> /// </summary>
> 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.SuspendLayout();
> //
> // button1
> //
> this.button1.Location = new
>System.Drawing.Point(32, 32);
> this.button1.Name = "button1";
> this.button1.Size = new
>System.Drawing.Size(80, 40);
> this.button1.TabIndex = 0;
> this.button1.Text = "&Client";
> this.button1.Click += new
>System.EventHandler(this.button1_Click);
> //
> // button2
> //
> this.button2.Location = new
>System.Drawing.Point(224, 32);
> this.button2.Name = "button2";
> this.button2.Size = new
>System.Drawing.Size(80, 40);
> this.button2.TabIndex = 1;
> this.button2.Text = "E&xit";
> //
> // Form1
> //
> this.AutoScaleBaseSize = new
>System.Drawing.Size(5, 13);
> this.ClientSize = new
>System.Drawing.Size(687, 467);
> this.ControlBox = false;
> this.Controls.Add(this.button2);
> this.Controls.Add(this.button1);
> this.FormBorderStyle =
>System.Windows.Forms.FormBorderStyle.None;
> this.MaximizeBox = false;
> this.MinimizeBox = false;
> this.Name = "Form1";
> this.Text = "Form1";
> this.Closing += new
>System.ComponentModel.CancelEventHandler
>(this.Form1_Closing);
> this.ResumeLayout(false);
>
> }
> #endregion
>
>
> private void button1_Click(object sender,
>System.EventArgs e)
> {
> Form2 form2=new Form2(m_Container);
> IMyForm myForm=form2 as IMyForm;
> m_Container.ShowModal(myForm);
> }
>
> private void Form1_Closing(object sender,
>System.ComponentModel.CancelEventArgs e)
> {
> mIsRunning=false;
> }
>
> }
>}
>
>Form2.cs - Code
>
>using System;
>using System.Drawing;
>using System.Collections;
>using System.ComponentModel;
>using System.Windows.Forms;
>
>namespace MyTest
>{
> /// <summary>
> /// Summary description for Form2.
> /// </summary>
> public class Form2 : System.Windows.Forms.Form,
>IMyForm
> {
> private IMyContainer m_Container=null;
> private System.Windows.Forms.Button
>button1;
> private System.Windows.Forms.TextBox
>textBox1;
> private System.Windows.Forms.Button
>button2;
> /// <summary>
> /// Required designer variable.
> /// </summary>
> private System.ComponentModel.Container
>components = null;
> private System.Windows.Forms.Button
>button3;
> private System.Windows.Forms.Label label1;
>
> private bool mIsRunning=true;
> public bool IsRunning()
> {
> return mIsRunning;
> }
>
> public Form2(IMyContainer myContainer)
> {
> m_Container=myContainer;
> //
> // Required for Windows Form
>Designer support
> //
> InitializeComponent();
>
> //
> // TODO: Add any constructor code
>after InitializeComponent call
> //
> }
>
> /// <summary>
> /// Clean up any resources being used.
> /// </summary>
> 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.textBox1 = new
>System.Windows.Forms.TextBox();
> this.button2 = new
>System.Windows.Forms.Button();
> this.button3 = new
>System.Windows.Forms.Button();
> this.label1 = new
>System.Windows.Forms.Label();
> this.SuspendLayout();
> //
> // button1
> //
> this.button1.Location = new
>System.Drawing.Point(216, 88);
> this.button1.Name = "button1";
> this.button1.Size = new
>System.Drawing.Size(80, 40);
> this.button1.TabIndex = 0;
> this.button1.Text = "E&xit";
> this.button1.Click += new
>System.EventHandler(this.button1_Click);
> //
> // textBox1
> //
> this.textBox1.Location = new
>System.Drawing.Point(96, 32);
> this.textBox1.Name = "textBox1";
> this.textBox1.Size = new
>System.Drawing.Size(168, 20);
> this.textBox1.TabIndex = 2;
> this.textBox1.Text = "";
> //
> // button2
> //
> this.button2.Location = new
>System.Drawing.Point(24, 88);
> this.button2.Name = "button2";
> this.button2.Size = new
>System.Drawing.Size(80, 40);
> this.button2.TabIndex = 3;
> this.button2.Text = "&Add";
> this.button2.Click += new
>System.EventHandler(this.button2_Click);
> //
> // button3
> //
> this.button3.Location = new
>System.Drawing.Point(120, 88);
> this.button3.Name = "button3";
> this.button3.Size = new
>System.Drawing.Size(80, 40);
> this.button3.TabIndex = 1;
> this.button3.Text = "&Change";
> this.button3.Click += new
>System.EventHandler(this.button3_Click);
> //
> // label1
> //
> this.label1.Location = new
>System.Drawing.Point(24, 32);
> this.label1.Name = "label1";
> this.label1.Size = new
>System.Drawing.Size(64, 24);
> this.label1.TabIndex = 3;
> this.label1.Text = "Enter Code:";
> //
> // Form2
> //
> this.AutoScaleBaseSize = new
>System.Drawing.Size(5, 13);
> this.ClientSize = new
>System.Drawing.Size(687, 467);
> this.ControlBox = false;
> this.Controls.Add(this.button3);
> this.Controls.Add(this.label1);
> this.Controls.Add(this.button2);
> this.Controls.Add(this.textBox1);
> this.Controls.Add(this.button1);
> this.FormBorderStyle =
>System.Windows.Forms.FormBorderStyle.None;
> this.MaximizeBox = false;
> this.MinimizeBox = false;
> this.Name = "Form2";
> this.Text = "Form2";
> this.ResumeLayout(false);
>
> }
> #endregion
>
> private void button1_Click(object sender,
>System.EventArgs e)
> {
> MessageBox.Show("Exit Button
>Pressed, Closing Form");
> mIsRunning=false;
> }
>
> private void button2_Click(object sender,
>System.EventArgs e)
> {
> MessageBox.Show("Add Button
>Pressed");
> textBox1.Focus();
>
> }
>
>
> private void button3_Click(object sender,
>System.EventArgs e)
> {
> MessageBox.Show("Change Button
>Pressed");
> textBox1.Focus();
> }
>
> }
>}
>
>AssemblyInfo.cs - Code
>
>using System.Reflection;
>using System.Runtime.CompilerServices;
>
>//
>// General Information about an assembly is controlled
>through the following
>// set of attributes. Change these attribute values to
>modify the information
>// associated with an assembly.
>//
>[assembly: AssemblyTitle("")]
>[assembly: AssemblyDescription("")]
>[assembly: AssemblyConfiguration("")]
>[assembly: AssemblyCompany("")]
>[assembly: AssemblyProduct("")]
>[assembly: AssemblyCopyright("")]
>[assembly: AssemblyTrademark("")]
>[assembly: AssemblyCulture("")]
>
>//
>// Version information for an assembly consists of the
>following four values:
>//
>// Major Version
>// Minor Version
>// Build Number
>// Revision
>//
>// You can specify all the values or you can default the
>Revision and Build Numbers
>// by using the '*' as shown below:
>
>[assembly: AssemblyVersion("1.0.*")]
>
>//
>// In order to sign your assembly you must specify a key
>to use. Refer to the
>// Microsoft .NET Framework documentation for more
>information on assembly signing.
>//
>// Use the attributes below to control which key is used
>for signing.
>//
>// Notes:
>// (*) If no key is specified, the assembly is not
>signed.
>// (*) KeyName refers to a key that has been installed
>in the Crypto Service
>// Provider (CSP) on your machine. KeyFile refers[/color]
to[color=blue]
>a file which contains
>// a key.
>// (*) If the KeyFile and the KeyName values are both
>specified, the
>// following processing occurs:
>// (1) If the KeyName can be found in the CSP, that
>key is used.
>// (2) If the KeyName does not exist and the[/color]
KeyFile[color=blue]
>does exist, the key
>// in the KeyFile is installed into the CSP and
>used.
>// (*) In order to create a KeyFile, you can use the
>sn.exe (Strong Name) utility.
>// When specifying the KeyFile, the location of the
>KeyFile should be
>// relative to the project output directory which is
>// %Project Directory%\obj\<configuration>. For
>example, if your KeyFile is
>// located in the project directory, you would
>specify the AssemblyKeyFile
>// attribute as [assembly: AssemblyKeyFile
>("..\\..\\mykey.snk")]
>// (*) Delay Signing is an advanced option - see the
>Microsoft .NET Framework
>// documentation for more information on this.
>//
>[assembly: AssemblyDelaySign(false)]
>[assembly: AssemblyKeyFile("")]
>[assembly: AssemblyKeyName("")]
>
>MyTest.csproj - Code
>
><VisualStudioProject>
> <CSHARP
> ProjectType = "Local"
> ProductVersion = "7.10.3077"
> SchemaVersion = "2.0"
> ProjectGuid = "{0EA4C813-3EDD-4AF1-A22C-
>B8B11F892AF1}"[color=green]
> >[/color]
> <Build>
> <Settings
> ApplicationIcon = "App.ico"
> AssemblyKeyContainerName = ""
> AssemblyName = "MyTest"
> AssemblyOriginatorKeyFile = ""
> DefaultClientScript = "JScript"
> DefaultHTMLPageLayout = "Grid"
> DefaultTargetSchema = "IE50"
> DelaySign = "false"
> OutputType = "WinExe"
> PreBuildEvent = ""
> PostBuildEvent = ""
> RootNamespace = "MyTest"
> RunPostBuildEvent = "OnBuildSuccess"
> StartupObject = ""[color=green]
> >[/color]
> <Config
> Name = "Debug"
> AllowUnsafeBlocks = "false"
> BaseAddress = "285212672"
> CheckForOverflowUnderflow = "false"
> ConfigurationOverrideFile = ""
> DefineConstants = "DEBUG;TRACE"
> DocumentationFile = ""
> DebugSymbols = "true"
> FileAlignment = "4096"
> IncrementalBuild = "false"
> NoStdLib = "false"
> NoWarn = ""
> Optimize = "false"
> OutputPath = "bin\Debug\"
> RegisterForComInterop = "false"
> RemoveIntegerChecks = "false"
> TreatWarningsAsErrors = "false"
> WarningLevel = "4"
> />
> <Config
> Name = "Release"
> AllowUnsafeBlocks = "false"
> BaseAddress = "285212672"
> CheckForOverflowUnderflow = "false"
> ConfigurationOverrideFile = ""
> DefineConstants = "TRACE"
> DocumentationFile = ""
> DebugSymbols = "false"
> FileAlignment = "4096"
> IncrementalBuild = "false"
> NoStdLib = "false"
> NoWarn = ""
> Optimize = "true"
> OutputPath = "bin\Release\"
> RegisterForComInterop = "false"
> RemoveIntegerChecks = "false"
> TreatWarningsAsErrors = "false"
> WarningLevel = "4"
> />
> </Settings>
> <References>
> <Reference
> Name = "System"
> AssemblyName = "System"
> HintPath
>= "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322[/color]
\System.dll"[color=blue]
> />
> <Reference
> Name = "System.Data"
> AssemblyName = "System.Data"
> HintPath
>= "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322
>\System.Data.dll"
> />
> <Reference
> Name = "System.Drawing"
> AssemblyName = "System.Drawing"
> HintPath
>= "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322
>\System.Drawing.dll"
> />
> <Reference
> Name = "System.Windows.Forms"
> AssemblyName = "System.Windows.Forms"
> HintPath
>= "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322
>\System.Windows.Forms.dll"
> />
> <Reference
> Name = "System.XML"
> AssemblyName = "System.XML"
> HintPath
>= "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322
>\System.XML.dll"
> />
> </References>
> </Build>
> <Files>
> <Include>
> <File
> RelPath = "App.ico"
> BuildAction = "Content"
> />
> <File
> RelPath = "AssemblyInfo.cs"
> BuildAction = "Compile"
> />
> <File
> RelPath = "Form1.cs"
> SubType = "Form"
> BuildAction = "Compile"
> />
> <File
> RelPath = "Form2.cs"
> SubType = "Form"
> BuildAction = "Compile"
> />
> <File
> RelPath = "FuncClass1.cs"
> SubType = "Code"
> BuildAction = "Compile"
> />
> <File
> RelPath = "MainForm.cs"
> SubType = "Form"
> BuildAction = "Compile"
> />
> </Include>
> </Files>
> </CSHARP>
></VisualStudioProject>
>
>
>
>
>
>
>
>.
>[/color]