Solved

Pressing Escape on Dialog Sends Event to Parent

Posted on 2006-06-15
3
267 Views
Last Modified: 2008-03-17
I'm trapping the Escape key in the KeyUp event of one of my forms. There is also another item that shows a windows for user input using the ShowDialog() method (I need it to block, that's why it's a dialog). The problem is that when the user presses escape on the dialog the parent window seems to get the event (and closes the form, as it should). I can't seem to find a way to detect if the escape press came from the dialog or not.. Obviously I only want the dialog to close (and return Cancel) - I don't want the opening window to see the Escape press event at all if possible but I'd like to be able to tell that it came from the dialog so I can add a conditional in there that will prevent the form close.

Help!

Thanks!
0
Comment
Question by:mitchvincent
  • 2
3 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 500 total points
ID: 16911403
I think that dialog is closed by Esc KeyDown using standard dialog support - CancelButton. Instead of this handle Esc KeyUp event in the dialog and close it.
0
 

Author Comment

by:mitchvincent
ID: 16911603
That's it!

Gosh, I'm sure glad you have your thinking cap on today - mine is at the house I guess..

Thanks very much!

As a side note, when I press escape on the dialog and trap the event in the KeyUp, I do get a "beep", the one you get when trying to type somewhere you shouldn't in a windows application.

0
 
LVL 48

Expert Comment

by:AlexFM
ID: 16918065
Another solution is to close form in Esc Keydown event. In this case you don't need to change dialog.
0

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

746 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

13 Experts available now in Live!

Get 1:1 Help Now