Solved

disabling 'return' beeps in edit box

Posted on 1998-04-23
7
441 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Windows Drag & Drop Location 2 108
cat dog challenge 18 126
Shell script to login to remote m/c and execute commands 10 78
Way to decrease size of apk file 9 86
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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 a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

860 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