|
-
June 4th, 2002, 05:38 PM
#1
CEdit Box Question
Hey there!
I just started playing around with VC++ .net and already discovered a problem I can't explain 
When I create a Dialog-Based Application with only one CEdit Editbox on the Dialog, the compiled Application will close as soon as I press RETURN. How can I prevent/suppress that?
The CEdit property "Want Return" set to "true" does not seem to work here ... any suggestions?
Thanks in advance ...
-
June 6th, 2002, 06:20 PM
#2
This is rather MFC question.
RETURN is automatically translated to WM_COMMAND with ID 0x00000001 – equivalent of pressing OK button. Even if you get rid of the IDOK framework will still supply this message to a dialog and in turn dialog will close.
There is many ways of changing that behavior: deriving own CEdit based class and handle PreTranslateMessage, override PreTranslateMessage in dialog or overriding OnOK virtual member of the CDialog class:
Code:
void CDlgReturnFix::OnOK(void)
{
CWnd* pWnd = GetFocus();
if(GetDlgItem(IDOK) == pWnd)
{
CDialog::OnOK();
return;
}
NextDlgCtrl(); //will move focus to next control in tab order
}
There are only 10 types of people in the world:
Those who understand binary and those who do not.
-
December 27th, 2003, 08:11 AM
#3
You need to set "Default button" option for OK button to FALSE.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|