Solved

Pressing Escape on Dialog Sends Event to Parent

Posted on 2006-06-15
3
291 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

695 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