Key strokes on MDI parent forms

Posted on 2005-05-07
Last Modified: 2010-04-23
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

Question by:davoman
    LVL 34

    Accepted Solution

    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
            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.

    LVL 14

    Expert Comment

    That works. Just a complement, also do the same thing on your parent form.
    LVL 1

    Author Comment

    just as an aside if, i want other key presses to be picked up by the child form, will that still be allowed
    LVL 34

    Expert Comment


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

    LVL 1

    Author Comment

    thanks for the help

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    Article by: jpaulino
    XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String ( Literal, only instead of starting and ending with w…
    I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now