Bell sound when ENTER is pressed in an EDIT control child of an ATL control 
Author Message
 Bell sound when ENTER is pressed in an EDIT control child of an ATL control

I create an EDIT control as a child window of my full (always windowed) ATL
control.  My ATL control Oncreate looks like this:

LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
  // Create a vanilla Windows EDIT control on the ATL window:
      HWND hWnd = CreateWindow("EDIT", "", WS_CHILD | WS_VISIBLE,
                               1, 1, 120, 22, m_hWnd, NULL, NULL, NULL);
  return 0;

Quote:
}

When the EDIT control has focus and ENTER (or TAB) is pressed, a "ding" bell
sound is issued.  This happens when the ATL control is embedded in VB, VC++
(CFormView) and the ActiveX Test Container, but not in a VC++ dialog box.
Other characters do not sound the bell, and the expected Windows messages
(WM_KEYDOWN etc.) are issued in all cases so the EDIT control is clearly
getting the ENTER keystroke.

An essentially identical MFC OCX control does not produce the ding sound.
How can I suppress the ding sound in my ATL control?

TIA, Jennifer.



Mon, 28 Oct 2002 03:00:00 GMT  
 Bell sound when ENTER is pressed in an EDIT control child of an ATL control
This is the standard behaviour of a single-line edit control, except in a
dialog box where the default OK button normally traps the enter key.
If you set the focus to some other control in response to WM_KEYDOWN for the
enter key, that should prevent the beeping.

Peter


Quote:
> I create an EDIT control as a child window of my full (always windowed)
ATL
> control.  My ATL control Oncreate looks like this:

> LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
> {
>   // Create a vanilla Windows EDIT control on the ATL window:
>       HWND hWnd = CreateWindow("EDIT", "", WS_CHILD | WS_VISIBLE,
>                                1, 1, 120, 22, m_hWnd, NULL, NULL, NULL);
>   return 0;
> }

> When the EDIT control has focus and ENTER (or TAB) is pressed, a "ding"
bell
> sound is issued.  This happens when the ATL control is embedded in VB,
VC++
> (CFormView) and the ActiveX Test Container, but not in a VC++ dialog box.
> Other characters do not sound the bell, and the expected Windows messages
> (WM_KEYDOWN etc.) are issued in all cases so the EDIT control is clearly
> getting the ENTER keystroke.

> An essentially identical MFC OCX control does not produce the ding sound.
> How can I suppress the ding sound in my ATL control?

> TIA, Jennifer.



Tue, 29 Oct 2002 03:00:00 GMT  
 Bell sound when ENTER is pressed in an EDIT control child of an ATL control
Thanks!  Your solution was not quite the one I was looking for because I
didn't want to change the focus when Enter is pressed.  It turns out that
the correct solution is to override PreTranslateAccelerator in the ATL
control and then convey the WM_KEYDOWN, WM_KEYUP and WM_CHAR for Enter, Tab
and arrow keys directly to the child EDIT control via SendMessage.

The clue was in KB article Q232624, which has been mentioned elsewhere in
this newsgroup.  I'm not exactly sure of why this works (perhaps because
subsequent processing is suppressed by returning a non-zero value from
PreTranslateAccelerator), but it did eliminate the "ding" problem.  As an
added benefit, this also solves the Form navigation key problem in VB and
some other containers.

Jennifer


Quote:
> This is the standard behaviour of a single-line edit control, except in a
> dialog box where the default OK button normally traps the enter key.
> If you set the focus to some other control in response to WM_KEYDOWN for
the
> enter key, that should prevent the beeping.

> Peter



> > I create an EDIT control as a child window of my full (always windowed)
> ATL
> > control.  My ATL control Oncreate looks like this:

> > LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled)
> > {
> >   // Create a vanilla Windows EDIT control on the ATL window:
> >       HWND hWnd = CreateWindow("EDIT", "", WS_CHILD | WS_VISIBLE,
> >                                1, 1, 120, 22, m_hWnd, NULL, NULL, NULL);
> >   return 0;
> > }

> > When the EDIT control has focus and ENTER (or TAB) is pressed, a "ding"
> bell
> > sound is issued.  This happens when the ATL control is embedded in VB,
> VC++
> > (CFormView) and the ActiveX Test Container, but not in a VC++ dialog
box.
> > Other characters do not sound the bell, and the expected Windows
messages
> > (WM_KEYDOWN etc.) are issued in all cases so the EDIT control is clearly
> > getting the ENTER keystroke.

> > An essentially identical MFC OCX control does not produce the ding
sound.
> > How can I suppress the ding sound in my ATL control?

> > TIA, Jennifer.



Tue, 29 Oct 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Controlling length of ASCII bell sound output

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

3. Edit Control...Edit Control...Edit Control...Edit Control...Edit Control...

4. Press enter in edit box?

5. Pressing ENTER in an edit box

6. Enter pressed in an edit box

7. Filtering key presses in an edit control

8. Edit Control---- Edit control ----------------------

9. rich edit control without TAB, ENTER, BACKSPACE functionality

10. Handling 'Enter' in Edit Control

11. Using Rich Edit Control or ip address control in a composite control

12. cannot trap the enter key using atl control that is hosted in a container

 

 
Powered by phpBB® Forum Software