Solved

Disable the enter button

Posted on 1998-10-31
4
171 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
[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
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

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

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: 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…
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.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

696 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