Solved

disabling 'return' beeps in edit box

Posted on 1998-04-23
7
435 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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Named range not carried over 10 63
iSeries DB2 Query 2 95
noX challenge 17 117
Remove Password Protection from pdf (with password) using an command line executable 5 52
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…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

810 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