Link to home
Start Free TrialLog in
Avatar of mitchvincent
mitchvincent

asked on

Pressing Escape on Dialog Sends Event to Parent

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!
ASKER CERTIFIED SOLUTION
Avatar of AlexFM
AlexFM

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mitchvincent
mitchvincent

ASKER

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.

Another solution is to close form in Esc Keydown event. In this case you don't need to change dialog.