Solved

Disable the enter button

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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 is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

932 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

10 Experts available now in Live!

Get 1:1 Help Now