Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Pressing Escape on Dialog Sends Event to Parent

Posted on 2006-06-15
3
Medium Priority
?
302 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 2000 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

618 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