Solved

Intercepting Carriage Return in Modal Dialog

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
iSeries DB2 Query 2 84
dog bark java program 15 82
move a line in eclipse 3 60
has22 challenge 11 72
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now