Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Disable the enter button

Posted on 1998-10-31
4
Medium Priority
?
173 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 200 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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 Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

596 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