Enter pressed in an edit box 
Author Message
 Enter pressed in an edit box

Hi all,

I'd need some help with a UI that I am currently creating: I have a few
edit boxes in a dialog. The problem is that, when I have edited the text
in the edit box and press Enter, the dialog is dismissed. I don't want
that to happen! I just want the focus to jump to the next edit box.

What is the trick to prevent this from happening?

Kind regards,
Martin



Mon, 12 May 2003 03:00:00 GMT  
 Enter pressed in an edit box

Quote:
>I'd need some help with a UI that I am currently creating: I have a few
>edit boxes in a dialog. The problem is that, when I have edited the text
>in the edit box and press Enter, the dialog is dismissed. I don't want
>that to happen! I just want the focus to jump to the next edit box.

>What is the trick to prevent this from happening?

Martin,

Try something like this:

BOOL CAboutDlg::PreTranslateMessage(MSG* pMsg)
{
        if (    ( pMsg->message == WM_KEYDOWN ) &&
                ( pMsg->wParam == VK_RETURN ) )
        {
                PostMessage( WM_NEXTDLGCTL, 0, false );

                return true;
        }
        else
                return CDialog::PreTranslateMessage(pMsg);

Quote:
}

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
My address is altered to discourage junk mail.
Please post responses to the newsgroup thread,
there's no need for follow-up email copies.


Mon, 12 May 2003 03:00:00 GMT  
 Enter pressed in an edit box

Quote:
>Hi all,

>I'd need some help with a UI that I am currently creating: I have a few
>edit boxes in a dialog. The problem is that, when I have edited the text
>in the edit box and press Enter, the dialog is dismissed. I don't want
>that to happen! I just want the focus to jump to the next edit box.

>What is the trick to prevent this from happening?

A simple trick is to get rid of the default on the OK button, or set the
focus away from it.

Gerry Quinn                                  
--
http://bindweed.com
Entertainment software for Windows
Puzzles, Strategy Games, Kaleidoscope Screensaver
Download evaluation versions free - no time limits



Mon, 12 May 2003 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. press enter in an edit box and make it happen in an other edit box too

2. Press enter in edit box?

3. Pressing ENTER in an edit box

4. Bell sound when ENTER is pressed in an EDIT control child of an ATL control

5. Pressing enter in combo box

6. pressing ENTER in CEdit box

7. Why pressing Enter key closes my dialog box?

8. Pressing Enter in Dialog Box

9. How to prevent my modal dialog box from destruction when I press enter

10. How to prevent my modal dialog box from destruction when I press enter

11. Handling the User Pressing Return in Edit box

12. Processing TAB and ENTER (RETURN) from edit box in dialog

 

 
Powered by phpBB® Forum Software