Solved

disabling 'return' beeps in edit box

Posted on 1998-04-23
7
430 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sameEnds challenge 3 134
string initialization in java 11 110
no14 challenge 14 62
SQUD PROXY SERVER, UNIX, SLL/HTTPS 5 74
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

910 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

21 Experts available now in Live!

Get 1:1 Help Now