Valhalla Legends Forums Archive | C/C++ Programming | Unwanted Beeping

AuthorMessageTime
Spilled[DW]
I read the post a few days back on the unwanted beeping and im getting the same problem. I tried what MyndFyre said but im still getting the beeping...

Here some code:
[code]
LRESULT CALLBACK SendProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
switch(msg)
{
case WM_KEYDOWN:
{
            if((int)wParam == VK_RETURN)
            {
             
              if(GetWindowTextLength(rtbSend) != 0)
              {
                  char* g = new char[GetWindowTextLength(rtbSend)];                     
                  GetWindowText(rtbSend,g,GetWindowTextLength(rtbSend)+1);
                  buffer pBuffer;
                  pBuffer.InsertNTString(g);
                  pBuffer.SendBNCSPacket(wSock,0x0E);
                 
                  AppendWindowText(rtbChat,"\n");
                  AppendWindowText(rtbChat,"<");
                  AppendWindowText(rtbChat,sUser);
                  AppendWindowText(rtbChat,"> ");
                  AppendWindowText(rtbChat,g);
                 
                  SetWindowText(rtbSend,NULL);
                 
              }
            }
        return 0;   
        }
        break;
    default:                      /* for messages that we don't deal with */
            return CallWindowProc(myProc,hwnd,msg,wParam,lParam);
            //return CallWindowProc(xMainProc,hwnd,msg,wParam,lParam);
    }
    return 0;
}
[/code]

Even in the WindowProcedure before it gets the Default, I tried this:

[code]
        case WM_KEYDOWN:
            {
            return 0;
            }
            break;
[/code]

Any ideas on why it's still beeping.....?
February 13, 2006, 3:54 AM
JoeTheOdd
I can almost garantee I'm wrong, but the only thing I can think of is setting (int)wParam != VK_RETURN.
February 13, 2006, 6:13 AM
Spilled[DW]
I even tried:
[code]
switch(message)
{
  case WM_CHAR:
        if((TCHAR)wParam == '\r')
  break;
}
[/code]

Still beeps, any other ideas?
February 13, 2006, 6:38 AM
Zakath
Odd. Hmm...from your code it appears that you used a rich text box and not an edit box for your "send" control. Is this the case?
February 13, 2006, 7:11 PM
Spilled[DW]
Well I started off using a rtb but found it was harder to subclass so i switched to an Edit control.

[code]
                 rtbSend = CreateWindowEx(WS_EX_CLIENTEDGE,
                           TEXT("EDIT"),
                           TEXT(""),
                           WS_CHILD|WS_VISIBLE|WS_BORDER,
                           10,
                           320,
                           670,
                           20,
                           hwnd,
                           (HMENU)SendBar_ID,
                           myInst,
                           NULL
                           );
[/code]

Even so, I dont see how there would be a difference? Can you clear this up for me? Thanks in advance
February 13, 2006, 8:25 PM
Zakath
I have a subclassed edit control, I capture WM_CHAR, and it doesn't beep at all. I need a bit more context. Where do you make the call that replaces the WndProc for the edit control? I do it in the WM_INITDIALOG for the parent window (if you create the main window using CreateWindowEx you'd be using WM_CREATE instead).
February 13, 2006, 9:03 PM
Spilled[DW]
Yes I Subclass the edit control in the main window procedure, Like so:

[code]
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)                  /* handle the messages */
    {
        case WM_CREATE:
    rtbSend = CreateWindowEx(WS_EX_CLIENTEDGE,
            "EDIT",
            TEXT(""),
            WS_CHILD|WS_VISIBLE|WS_BORDER,
            10,
            320,
            670,
            20,
            hwnd,
            (HMENU)SendBar_ID,
            myInst,
            NULL
            );
                       myProc = (WNDPROC)SetWindowLong(rtbSend,GWL_WNDPROC,(LONG)SendProc);
             break;
[/code]

Any ideas?

Edit: fixed code tags
February 13, 2006, 10:10 PM
shout
I think it has something to do with something being sent to defaultwndproc or w/e.
February 14, 2006, 3:07 AM
Spilled[DW]
but in the proc I return 0, Like so:

[code]
case WM_KEYDOWN:
{
            if((int)wParam == VK_RETURN)
            {
             
              if(GetWindowTextLength(rtbSend) != 0)
              {
                  char* g = new char[GetWindowTextLength(rtbSend)];                     
                  GetWindowText(rtbSend,g,GetWindowTextLength(rtbSend)+1);
                  buffer pBuffer;
                  pBuffer.InsertNTString(g);
                  pBuffer.SendBNCSPacket(wSock,0x0E);
                 
                  AppendWindowText(rtbChat,"\n");
                  AppendWindowText(rtbChat,"<");
                  AppendWindowText(rtbChat,sUser);
                  AppendWindowText(rtbChat,"> ");
                  AppendWindowText(rtbChat,g);
                 
                  SetWindowText(rtbSend,NULL);
                 
              }
            }
        return 0;   
        }
        break;
[/code]

Am I doing soemthing wrong? Im creating it with CreateWindowEx() so i cant use WM_CHAR.... any other ideas guys?
February 14, 2006, 6:40 AM
warz
Solved here: [Win32] Unwanted beep while looking for VK_RETURN within WM_KEYDOWN
February 14, 2006, 8:06 AM
Spilled[DW]
Solved: I wasn't returning 0 on WM_CHAR and WM_KEYUP so that was going to default proc and beeping. Thanks for the help once again guys.
February 14, 2006, 7:16 PM

Search