Solved

Question on ENTER key

Posted on 1998-11-06
10
210 Views
Last Modified: 2013-11-20
Hi there,
         I've got a problem whenever I run my visual c++ program, the main window popped up but whenever I pressed the ENTER key, it'll destroy itself. Is there any way to capture the ENTER key and stop the window from destroying itself when the ENTER key is pressed? For ur info. I'm using MSVC 5.0 and my program is dialog-based and I'm working on a win98 platform.

Any help offered will be very much appreciated!
0
Comment
Question by:justinng
  • 5
  • 5
10 Comments
 
LVL 23

Accepted Solution

by:
naveenkohli earned 20 total points
ID: 1324302
Capture your OnOK button message. And don't call the base class's OnOK function. This is the one which is making your app to close down
e.g. for dialog box

CMyDialog::OnOK ()
{
   CDialog::OnOK ();
}

The above code will make the app to close. Instead you wanna to have

CMyDialog::OnOK ()
{
}
0
 

Author Comment

by:justinng
ID: 1324303
sorry but i didn't see any CDialog::OnOK (); hehee

0
 

Author Comment

by:justinng
ID: 1324304
sorry but i didn't see any CDialog::OnOK (); hehee

0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:justinng
ID: 1324305
If i don't call the OnOK(); function... if there's a mouse click on the "Done" button... the window will not destroy itself... is there another other ways?
0
 
LVL 23

Expert Comment

by:naveenkohli
ID: 1324306
You won't see OnOK () function call. You will have to override this call. And this will be the simplest solution to your problem.
0
 

Author Comment

by:justinng
ID: 1324307
Erm.. hehe... can u please tell me how to go about overwriting it? thanks!
0
 

Author Comment

by:justinng
ID: 1324308
I think I've overwritten it because the window won't destroy itself after I pressed the ENTER key but however.. when I clicked on the "Done" button... the program still cannot terminate... Is there any ways to terminate it when "Done" button is clicked?

0
 
LVL 23

Expert Comment

by:naveenkohli
ID: 1324309
Simple solution..
At the end of Done () function ..put
CDialog::OnOK ()....

This will do the job for you.
0
 
LVL 23

Expert Comment

by:naveenkohli
ID: 1324310
Sorry about the last solution...
This won't work...

0
 
LVL 23

Expert Comment

by:naveenkohli
ID: 1324311
Alrite! Finally...

Call
 ::PostQuitMessage (int code) API function at the end of your Done () function. And code can be any integer you like. It simply represent the exit code.

I hope this will solve your problem.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying 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

Suggested Solutions

Title # Comments Views Activity
xyBalance chalenge 58 96
Folder Comparison 12 54
My project did see openJDK that I installed. What could be the problem 7 152
SQUD PROXY SERVER, UNIX, SLL/HTTPS 5 104
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…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

830 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