Solved

Disappearing Dialog

Posted on 2001-07-28
10
331 Views
Last Modified: 2013-11-20
I have dialog-based application in which a dialog box is displayed once the user presses a button on the initial screen.  The problem is if the user presses the "ENTER" key in one of the edit boxes of the dialog box, the dialog box closes and the focus shifts back to the initial screen.  How can I make it so that the dialog box does not close (or disappear) until the user presses the "OK" button?
0
Comment
Question by:cneaton
10 Comments
 
LVL 32

Accepted Solution

by:
jhance earned 50 total points
Comment Utility
Add a handler for OnOK using the Class Wizard and be sure to do something other than call the CDialog::OnOK() handler which will close the dialog.
0
 

Expert Comment

by:chual
Comment Utility
Your "OK" button is set as default button. As a result, Pressing the "ENTER" button will amount to clicking on the "OK" button. Change the style of the "OK" button by unchecking the "Default" style.

chua
0
 

Expert Comment

by:chual
Comment Utility
I meant changing the properties of the "OK" button by unchecking the "Default button" style.
0
 
LVL 42

Expert Comment

by:sedgwick
Comment Utility
do u have an OK button on your dialog?
if u do, change its ID to ID_OK and handle its click:
CDialog::OnOK();
0
 

Expert Comment

by:chual
Comment Utility
Since he still wants to allow the user clicking OK to close the dialog box, he does not need to do anything with his OnOK() handler. Simply changing the property of the OK button will do the job.
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Expert Comment

by:chual
Comment Utility
hi cneaton,

how are you getting along with your problem? were you able to get it work or you still need more clarification?

chual
0
 

Expert Comment

by:Sundar
Comment Utility
The comments given previously will exactly predict ur problem and u can solve them easily. I will give it some more clear (It will be useful if u are a biginner).

Please know some some thing about the property Default of a push button.

When u log into windows or some other application u might have found that after typing ur password just pressing enter will (accepts ur password) close the login dialog and logs u in (Keep in mind that u haven't pressed the OK button). This happens because of the Default property of the OK Button.

If u press Esc key on the same dialog u might have found the dialog closes ignoring ur password and other changes this is due to the Cancel property of the Cancel Button in the doalog.

As in the previous comments remove the Default property of the OK button. To do that right-click on the OK button select properties. in the properties dialog go to styles Tab there uncheck the Default Button check box.
0
 

Expert Comment

by:Sundar
Comment Utility
If ur dialog still closes due to Esc/Enter Keys I will give u the code to remove that (if u want it) !!
0
 
LVL 1

Expert Comment

by:pkreddy
Comment Utility
Hi,
 Open the EditBox properties window and check mark the  style "Want Return", this will solve the problem.
-- PK
0
 

Author Comment

by:cneaton
Comment Utility
Hello everyone, and thanks for the comments.  My dialog didn't have an "OK" button on it, so I just overrode the OnOK function since the dialog equated pressing the "ENTER" key to hitting the OK button.  Thanks again for all of your help!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
ODBC Connection Logging, ADO.NET 6 49
isEverywhere  challenge 19 64
Window placement 17 64
fix34  challenge 9 95
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: 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…
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.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

744 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

11 Experts available now in Live!

Get 1:1 Help Now