Solved

Beeping when pressing enter in edit box.

Posted on 2002-05-28
2
617 Views
Last Modified: 2013-12-03
Hi,

This is driving ME NUTZ.

I have subclassed the control so I can press the enter key and send a message to the main window to process the text in the window.  But, every time I press Enter it dings at me (like an error beep).  I have stepped thru it all, and when I press enter, the message is being sent, the text is retrieved, and the edit box is cleared.  But I have NO CLUE as to why this beeping is going on.

Anyone, please...

Here is my subclass function:

LRESULT CALLBACK EditProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
          switch (message)
          {
          case WM_KEYDOWN:
               if (wParam == VK_RETURN)
               {
                    SendMessage(MainWnd,WM_COMMAND,MAKEWPARAM(SENDDATA,0),0);
                   
               }
               break;
         
          }

          return CallWindowProc(OldEdit,hwnd,message,wParam,lParam);

}

Here is my case statement for SENDDATA:

case SENDDATA:
               // process and send the data to the server.
          //     SendMessage(hEditBox,WM_GETTEXT,(WPARAM)200, (LPARAM)CommandBuffer);
               GetWindowText(hEditBox,CommandBuffer,200);
               ProcessCommand(sock,CommandBuffer);
               SetWindowText(hEditBox,"");
               break;
0
Comment
Question by:navigator010897
2 Comments
 
LVL 4

Accepted Solution

by:
mblat earned 100 total points
Comment Utility
Try to overwrite WM_CHAR message for VK_RETURN and DON'T pass it to default window's handler...

Hope it helps...
0
 
LVL 1

Author Comment

by:navigator010897
Comment Utility
Heck, I never thought about the WM_CHAR message.  I had tried originally doing a return 0 on the WM_KEYDOWN for VK_RETURN, but it didn't change a thing.

I did a return 0 for the WM_CHAR of it, and it worked like a charm.  Thanks!
0

Featured Post

What Security Threats Are You Missing?

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

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This video discusses moving either the default database or any database to a new volume.

743 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

10 Experts available now in Live!

Get 1:1 Help Now