• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 226
  • Last Modified:

Key strokes on MDI parent forms

Hi there

I have an MDI parent form i want to capture key strokes for

basically if they press ESC i want the prent to run the code and not on any of the child forms that my be open

fundementally i want the user to be able to press escape and close the parent down

is this possible

cheers
0
davoman
Asked:
davoman
  • 2
  • 2
1 Solution
 
SanclerCommented:
If you set the child form's KeyPreview property to true, and include the following code in the child form's KeyPress sub

        If e.KeyChar = Chr(27) Then
            Me.MdiParent.Close()
        End If

that should achieve "i want the user to be able to press escape and close the parent down".  It's rough, but it works.

Roger
0
 
amyhxuCommented:
That works. Just a complement, also do the same thing on your parent form.
0
 
davomanAuthor Commented:
just as an aside if, i want other key presses to be picked up by the child form, will that still be allowed
0
 
SanclerCommented:
Yes.

The code only does anything at all if it is the Escape key which is pressed

Roger
0
 
davomanAuthor Commented:
thanks for the help
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now