Solved

Disable the enter button

Posted on 1998-10-31
4
166 Views
Last Modified: 2013-11-20
I have created a dialog box in visual c++ 5.0.  For some reason the dialog box wants to close the application when the user presses the enter button on the keyboard.  I have tried several things to stop this, such as using the pretranslatemessage() and even disabling and deleting the 2 default buttons, but none of them have worked.  Can anyone help me please?
0
Comment
Question by:SileNcer
  • 3
4 Comments
 
LVL 6

Accepted Solution

by:
thresher_shark earned 50 total points
ID: 1324103
Answer coming...
0
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1324104
Sure!  Here is what you want to do:
1) Go into the dialog's header file.

2) Add:
   void OnOK ();
   in the public: section within the dialog class.

3) Go into the source file (.cpp) of your dialog box.

4) Add:
   void CYourDlgClass::OnOK ()
   {
   }
   to the end of the file.

5) Recompile the program and run it.

The problem is that the enter key is by default the same thing as clicking the ok button, which closes the dialog.  You don't want that to happen, so it is a simple case of overriding the default behaviour, which is to close the dialog.

If for some reason this doesn't work, or you have any additional questions, please don't hesitiate to ask.  Thanks!
0
 

Author Comment

by:SileNcer
ID: 1324105
That worked perfectly!  Thanks thresher shark for your help!
0
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1324106
Sure no problem.  Glad I could help! :-)
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
sum67 challenge 35 89
lucky13 challenge 11 111
tripleUp challenge 7 65
canBalance challenge 34 65
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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 …
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.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

708 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

18 Experts available now in Live!

Get 1:1 Help Now