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

x
?
Solved

Intercepting Carriage Return in Modal Dialog

Posted on 1997-11-04
4
Medium Priority
?
264 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
[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
4 Comments
 
LVL 23

Accepted Solution

by:
chensu earned 800 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Suggested Courses

610 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