Solved

disabling 'return' beeps in edit box

Posted on 1998-04-23
7
428 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
  • 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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 20 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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

760 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now