?
Solved

disabling 'return' beeps in edit box

Posted on 1998-04-23
7
Medium Priority
?
458 Views
Last Modified: 2013-11-19
I am using a single-line edit box to manipulate some values.  How do you disable the beep
that occurs every time a 'return' is pressed.  (I have a OnKeyDown function which handles
a 'return' correctly, but I can't seem to get rid of the beep).
0
Comment
Question by:msmith2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 10

Expert Comment

by:RONSLOW
ID: 1301849
It is because there is no default button in your dialog.

0
 

Author Comment

by:msmith2
ID: 1301850
How do you create a default button?  It doesn't matter if it doesn't do anything as long as the beep is disabled.
0
 

Author Comment

by:msmith2
ID: 1301851
How do you create a default button?  It doesn't matter if it doesn't do anything
     as long as the beep is disabled.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 10

Expert Comment

by:RONSLOW
ID: 1301852
If you have an OK button, it is usally marked as the default.

If none of your buttons have the thicker border around them to indicate that they are the default button, then edit your dialog, pick a button that you want to have respond to the enter key and sets its style to default.

Now the enter key will activate that button when you pressed.

Unless you have stuffed up the handling of it with your OnKeyDown

0
 

Author Comment

by:msmith2
ID: 1301853
My problem is, I don't have any buttons.  The edit box is a child window.  There are 32 total edit boxes.  they are contained in a CWnd.  The contents actually represent 32 data registers for an assember gui.  I only want return to set focus back to the parent window.
I accomplished this with OnKeyDown, but it doesn't do anything with the beeps.  Can I assign it a default button that doesn't actually appear on screen?  How would I designate this button as default (what is the style parameter)?
0
 
LVL 10

Accepted Solution

by:
RONSLOW earned 80 total points
ID: 1301854
Try this (you'll need to derive your own CMyEdit clas and use that inplace of CEdit)...

BOOL CMyEdit::PreTranslateMessage(MSG* pMsg) {
  if (pMsg->message == WM_KEYDOWN ) {
    if (pMsg->wParam == VK_RETURN) {
      ::TranslateMessage(pMsg);
      ::DispatchMessage(pMsg);
      return TRUE;      // DO NOT process further
    }
  }
  return CEdit::PreTranslateMessage(pMsg);
}

void CMyEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) {
  CWnd* pParent = GetParent();
  if (nChar == VK_RETURN) {
    pParent->SetFocus();
    return;
  }
  CEdit::OnChar(nChar, nRepCnt, nFlags);
}

0
 

Author Comment

by:msmith2
ID: 1301855
Thanks!  I already had my own edit class defined (CRegEdit).  That solution worked great
except that I had to comment out ::TranslateMessage  I think the OnChar function is also redundant to the OnKeyDown, although I will have to test this theory.  Thanks a lot for making me aware of the PreTranslateMessage function.  It is exactly what I needed.
0

Featured Post

Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

800 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