Solved

Intercepting Carriage Return in Modal Dialog

Posted on 1997-11-04
4
226 Views
Last Modified: 2013-11-20
I have a modal dialog which has an Edit control and
a radio box.  Whenever I hit carriage return when the Edit
control or a radio box button has focus, it causes the
dialog to close.  How can I stop this from happening?  I
would rather have the carriage returns ignored.
0
Comment
Question by:kaplan1
  • 2
4 Comments
 
LVL 23

Accepted Solution

by:
chensu earned 200 total points
ID: 1309368
This is the function of a dialog box. When you press Return key, it will activate the default pushbutton, such as the OK or Cancel button. Try overriding CDialog::OnKeyDown() (or OnKeyUp). When you detect it is a Return key, do nothing. Otherwise, call the base class function CDialog::OnKeyDown().
0
 

Author Comment

by:kaplan1
ID: 1309369
I overrode the CDialog::OnKeyDown() however this function is
not being called when I type in the edit contol.
0
 
LVL 23

Expert Comment

by:chensu
ID: 1309370
Yes, because the CEdit::OnKeyDown() is called in this case. Do you mean this method works when the radio button has focus and it does not when the edit control has focus?
0
 
LVL 2

Expert Comment

by:wpinto
ID: 1309371
Hi kaplan1,

The messages OnKeyDown(), OnKeyUp()... won't be called for a modal dialog box.

Check out Article ID: Q126874 in Microsoft KB for more info
PRB: Modal Dialog Box Prevents Calls to PreTranslateMessage

The article also suggests a solution, which if implemented will allow messages to be sent to the dialog box. Then you can trap the OnKeyDown() message... & check for the Return key.

Hope this helps

Wilfred
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Replacement selected text 2 63
Window placement 17 87
zeroMAx challenge 20 114
Increment column based of a FK 8 31
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

828 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