Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Force Ctrl+F1 to cycle between windows
Message
From
29/06/2008 11:43:36
 
 
To
25/06/2008 14:01:43
General information
Forum:
ASP.NET
Category:
Forms
Environment versions
Environment:
C# 2.0
Miscellaneous
Thread ID:
01326709
Message ID:
01327516
Views:
6
Andrus,

You say you overrode the OnKeyPress, but then you showed code for the ProcessCmdKey ... are you saying that you tried that instead? And did it work?

It should work, but you don't show your "custom processing". Here's what I did that works. This code belongs in the MdiParent, not the MdiChild:
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
  switch (keyData)
  {
	  case Keys.Control | Keys.F1:
	  case Keys.Control | Keys.Tab:
		  for (int i = 0; i < this.MdiChildren.Length; i++)
		{
			if (this.MdiChildren[i].Equals(this.ActiveMdiChild))
			{
				i++;
				if (i == this.MdiChildren.Length)
					i = 0;
				this.ActivateMdiChild(this.MdiChildren[i]);
				this.ActiveMdiChild.Activate();
				break;
			}
		}
	  return true;
  }
  return base.ProcessCmdKey(ref msg, keyData);
}
~~Bonnie



>MDI WinForms 2 application.
>I need that Ctrl+F1 cycles through windows like in VFP.
>
>I overrided MDI child form OnKeypress method but Ctrl+F1 press is ignored.
>
>How to force Ctrl+F1 to cycle between windows ?
>
>
>Andrus.
>
>protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
>{
> switch (keyData)
> {
> case Keys.Control | Keys.Tab:
> // ... custom processing occurs hear.
> return true;
>
> case Keys.Control | Keys.F1:
> keyData = Keys.Control | Keys.Tab ;
> break;
> }
> return base.ProcessCmdKey(ref msg, keyData);
>}
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform