?
Solved

How to not quit an application when ENTER is pressed?

Posted on 2003-11-27
3
Medium Priority
?
261 Views
Last Modified: 2013-11-20
I have created a simple MFC application but I don't want to close the program when the user pressed the Enter key.
I don't know how to change this property.
Can somebody help me out?

I am using VC++ 6.0

Thanks!
0
Comment
Question by:UltimateApocalypse
[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
3 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 200 total points
ID: 9835621
Overwrite PretranslateMessage in dialog class:

BOOL CMyDlg::PreTranslateMessage(MSG* pMsg)
{
    if( pMsg->message == WM_KEYDOWN )
    {
        if( pMsg->wParam == VK_RETURN ||  pMsg->wParam == VK_ESCAPE )  // Enter, Esc
        {
            ::TranslateMessage(pMsg);
            ::DispatchMessage(pMsg);
            return TRUE;
        }
    }
      
      return CDialog::PreTranslateMessage(pMsg);
}
0
 

Author Comment

by:UltimateApocalypse
ID: 9835642
Thanks!
0
 

Expert Comment

by:lucky_boy
ID: 9845040
Hi
I suggest simply to go to the resource editor and in the properties window for the default button, which is OK button by default, to uncheck the "Default button" option. /it is in the "Styles" page /
Good luck
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

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…
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.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

718 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