Solved

Intercepting Carriage Return in Modal Dialog

Posted on 1997-11-04
4
214 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
bobThere java chalenge 45 92
Strange date stored 22 123
Creating Labels and Frequency list style reports in SAS code 9 98
fizzArray  challenge 1 84
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

809 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