Solved

How to not quit an application when ENTER is pressed?

Posted on 2003-11-27
3
248 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
3 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 50 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
substring method in java 1 99
no14 challenge 14 62
sumHeights  challenge 17 66
x-bar in Google Sheets 2 27
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
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.

863 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

23 Experts available now in Live!

Get 1:1 Help Now