enter key 
Author Message
 enter key

Hi,

I would like to shut up the enter key from telling my dialog
box to close...

I'm programming with MFC and I don't know how to get rid of it.
It's really bad if a user presses enter in a edit box and the whole
dialog disappears even though you would have to click on Close
with your mouse...

Does anyone have a clue ?

Regards,
Stefan
--


In this EMail I expressed my own opinion, not BlueByte Software's
opinion...



Sat, 16 Oct 1999 03:00:00 GMT  
 enter key

I think that, by default, pressing the Enter key causes OnOK() to be
called.  You could try overriding OnOK() in your dialog code and NOT pass
it on to the base class version (I.E., just return).  Make sure you have
some way out though, like the Close button you mentioned.

HTW,

Tom



Quote:
> Hi,

> I would like to shut up the enter key from telling my dialog
> box to close...

> I'm programming with MFC and I don't know how to get rid of it.
> It's really bad if a user presses enter in a edit box and the whole
> dialog disappears even though you would have to click on Close
> with your mouse...

> Does anyone have a clue ?

> Regards,
> Stefan
> --


> In this EMail I expressed my own opinion, not BlueByte Software's
> opinion...



Sat, 16 Oct 1999 03:00:00 GMT  
 enter key

Quote:

> Hi,

> I would like to shut up the enter key from telling my dialog
> box to close...

> I'm programming with MFC and I don't know how to get rid of it.
> It's really bad if a user presses enter in a edit box and the whole
> dialog disappears even though you would have to click on Close
> with your mouse...

> Does anyone have a clue ?

> Regards,
> Stefan
> --


> In this EMail I expressed my own opinion, not BlueByte Software's
> opinion...

If you don't need the return key at all in your dialog, you can do
something like...

BOOL CMyDlg::PreTranslateMessage(MSG* pMsg)
{

        if(pMsg->message == WM_KEYDOWN) {

                if(pMsg->wParam == VK_RETURN)

                        return TRUE; // I think - also test FALSE
        }      

        return CDialog::PreTranslateMessage(pMsg);

Quote:
}

Cecil

--
Cecil Galbraith

Free programmer's utilities and MFC tips at
http://www.concentric.net/~cgalbrai



Sat, 16 Oct 1999 03:00:00 GMT  
 enter key

Stefan,

If you don't already have enough options, you can also make it a
multi-line edit box, in which case the enter key generates \r\n as text
in the edit box and does not close the dialog (or perform the default
button's function).

Ron Martin
Ann Arbor, MI

Quote:

> Hi,

> I would like to shut up the enter key from telling my dialog
> box to close...

> I'm programming with MFC and I don't know how to get rid of it.
> It's really bad if a user presses enter in a edit box and the whole
> dialog disappears even though you would have to click on Close
> with your mouse...

> Does anyone have a clue ?

> Regards,
> Stefan
> --


> In this EMail I expressed my own opinion, not BlueByte Software's
> opinion...



Sat, 16 Oct 1999 03:00:00 GMT  
 enter key

Quote:

> Hi,

> I would like to shut up the enter key from telling my dialog
> box to close...

> I'm programming with MFC and I don't know how to get rid of it.
> It's really bad if a user presses enter in a edit box and the whole
> dialog disappears even though you would have to click on Close
> with your mouse...

> Does anyone have a clue ?

> Regards,
> Stefan
> --


> In this EMail I expressed my own opinion, not BlueByte Software's
> opinion...

Another way to do what you want is to use App Studio or the MSDev dialog
editor to change the properties of the "OK" button so it isn't the
default button on that dialog. Once you do that, hitting <Enter> won't
close the dialog box.
--
Stephen Goodney
All thoughts and opinions are mine alone.


Sat, 16 Oct 1999 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Enter Key must work as Tab Key do

2. Replace Tab key with Enter key

3. Enter Key acts as Tab Key ?

4. Changing the function of ENTER key to TAB key

5. Enter Key must work as Tab Key do

6. Trapping the enter key in a Datagrid cell

7. events : on pressing enter key ?

8. stop when Enter key is pressed

9. q: enter key in webform ?

10. capture 'enter key'

11. enter key event for a button

12. getting character without requiring enter key

 

 
Powered by phpBB® Forum Software