Solved

How to not quit an application when ENTER is pressed?

Posted on 2003-11-27
3
258 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 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Folder Comparison 12 56
deburging in oracle form 12 119
Use of condition with 'serial' in ansible 2 102
Adjust the codes 3 63
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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 video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.
Suggested Courses

738 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