v-lliu
6/26/2008 9:13:00 AM
Hi Sune,
Thank you for your quick response! I can reproduce the problem on my side
now.
As you have mentioned, the reason behind this issue is that the ToolStrip
class uses the following condition to determine whether Ctrl+Tab were
presssd:
(keyData & (Keys.Control | Keys.Tab)) == (Keys.Control | Keys.Tab))
The workaround is to derive from the ToolStrip class and override the
ProcessCmdKey method. If the Ctrl+K or something else except Ctrl+Tab that
meets the above condition were pressed, return false directly in the
override ProcessCmdKey method.
The following is a sample:
class MyToolStrip : ToolStrip
{
private bool CheckToolStrip(ToolStrip toolStrip, Keys keyData)
{
ToolStripDropDownButton ddb = null;
bool result = false;
for (int i = 0; i < toolStrip.Items.Count; i++)
{
if (toolStrip.Items[i].GetType() ==
typeof(ToolStripDropDownButton))
{
ddb = toolStrip.Items[i] as ToolStripDropDownButton;
for (int j = 0; j < ddb.DropDownItems.Count; j++)
{
if (ddb.DropDownItems[j].GetType() ==
typeof(ToolStripMenuItem))
{
result = CheckMenuItem(ddb.DropDownItems[j] as
ToolStripMenuItem, keyData);
if (result)
{ break; }
}
}
if (result)
{ break; }
}
}
return result;
}
private bool CheckMenuItem(ToolStripMenuItem menuitem, Keys keyData)
{
bool result = false;
if (menuitem.ShortcutKeys == keyData)
result = true;
else
{
for (int i = 0; i < menuitem.DropDownItems.Count; i++)
{
if (menuitem.DropDownItems[i].GetType() ==
typeof(ToolStripMenuItem))
{
result = CheckMenuItem(menuitem.DropDownItems[i] as
ToolStripMenuItem, keyData);
if (result)
{
break;
}
}
}
}
return result;
}
protected override bool ProcessCmdKey(ref Message m, Keys keyData)
{
if ((keyData != (Keys.Control | Keys.Tab)) && ((keyData &
(Keys.Control | Keys.Tab)) == (Keys.Control | Keys.Tab)))
{
if (CheckToolStrip(this, keyData))
return base.ProcessCmdKey(ref m, keyData);
else
return false;
}
else
return base.ProcessCmdKey(ref m, keyData);
}
}
Thank you for reporting this issue to us and your contribution to Microsoft
product! It will definitely improve our product.
If you have any concern, please feel free to let me know.
Sincerely,
Linda Liu
Microsoft Online Community Support
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@microsoft.com.
This posting is provided "AS IS" with no warranties, and confers no rights.