Can't Capture Ctrl-F4 in MDI Form

P

PMGuy

Hopefully, I'm missing something real simple in front of my face.


I've used the ProcessDialogKey override and I'm able to capture *most*
shortcut keystrokes, except for the one I'm really interested in.


It seems that the CTRL+F4 keystroke is being captured someplace before
my override can get it. Right now, because I can't capture the
CTRL-F4, the app uses ALT-X to close a MDI child. It works, but I hate

it.


What am I missing? Is there a setting someplace to force a MDI child
to execute the CLOSE() method? Does anyone know what is capturing the
CTRL+F4? I noticed a similar issue in VB6 that seemed to be related to

which types of controls had focus, but I couldn't actually duplicate
that in C#.NET.


Any help would be greatly appreciated.


NOTE: Here's the code that I'm using:


protected override bool ProcessDialogKey(Keys keyData)
{
switch (keyData)
{
case (Keys.Control | Keys.F4):
this.Close(); \\ NEVER FIRES
return true;
case (Keys.Alt | Keys.X):
this.Close(); \\ Used as a back-up to close form
return true;
};
return base.ProcessDialogKey(keyData)­;

NOTE: This is a duplicate post from the "general" group. I
cross-posted here because there seems to be more activity here. (I'm a
newbie)
 
P

PMGuy

I'm replying to myself for two reasons
1.) I'm hoping that "bumping" the thread prompts a response
or
2.) to conclude that my question is either too foolish to rate a
response or some undocumented M$ "feature" to which there is no
solution...
 
S

Sharpie

Have you set the KeyPreview property in the MDI child to true?

Hopefully, I'm missing something real simple in front of my face.


I've used the ProcessDialogKey override and I'm able to capture *most*
shortcut keystrokes, except for the one I'm really interested in.


It seems that the CTRL+F4 keystroke is being captured someplace before
my override can get it. Right now, because I can't capture the
CTRL-F4, the app uses ALT-X to close a MDI child. It works, but I hate

it.


What am I missing? Is there a setting someplace to force a MDI child
to execute the CLOSE() method? Does anyone know what is capturing the
CTRL+F4? I noticed a similar issue in VB6 that seemed to be related to

which types of controls had focus, but I couldn't actually duplicate
that in C#.NET.


Any help would be greatly appreciated.


NOTE: Here's the code that I'm using:


protected override bool ProcessDialogKey(Keys keyData)
{
switch (keyData)
{
case (Keys.Control | Keys.F4):
this.Close(); \\ NEVER FIRES
return true;
case (Keys.Alt | Keys.X):
this.Close(); \\ Used as a back-up to close form
return true;
};
return base.ProcessDialogKey(keyData)­;

NOTE: This is a duplicate post from the "general" group. I
cross-posted here because there seems to be more activity here. (I'm a
newbie)
 
P

PMGuy

KeyPreview is set to true... with no change in behavior. :-(

What tool can I use to find out where the Ctrl+F4 is getting captured?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top