Solved

Disable the enter button

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

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
Host to IP 7 83
either24  challenge 19 105
mapBully challenge 6 178
Capture logon name 13 106
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…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

730 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