Valhalla Legends Archive

Programming => General Programming => C/C++ Programming => Topic started by: Spilled on February 12, 2006, 09:54 PM

Title: Unwanted Beeping
Post by: Spilled on February 12, 2006, 09:54 PM
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:

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;
}


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


        case WM_KEYDOWN:
             {
             return 0;
             }
             break;


Any ideas on why it's still beeping.....?
Title: Re: Unwanted Beeping
Post by: Joe[x86] on February 13, 2006, 12:13 AM
I can almost garantee I'm wrong, but the only thing I can think of is setting (int)wParam != VK_RETURN.
Title: Re: Unwanted Beeping
Post by: Spilled on February 13, 2006, 12:38 AM
I even tried:

switch(message)
{
   case WM_CHAR:
         if((TCHAR)wParam == '\r')
   break;
}


Still beeps, any other ideas?
Title: Re: Unwanted Beeping
Post by: Zakath on February 13, 2006, 01:11 PM
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?
Title: Re: Unwanted Beeping
Post by: Spilled on February 13, 2006, 02:25 PM
Well I started off using a rtb but found it was harder to subclass so i switched to an Edit control.


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


Even so, I dont see how there would be a difference? Can you clear this up for me? Thanks in advance
Title: Re: Unwanted Beeping
Post by: Zakath on February 13, 2006, 03:03 PM
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).
Title: Re: Unwanted Beeping
Post by: Spilled on February 13, 2006, 04:10 PM
Yes I Subclass the edit control in the main window procedure, Like so:


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;


Any ideas?

Edit: fixed code tags
Title: Re: Unwanted Beeping
Post by: shout on February 13, 2006, 09:07 PM
I think it has something to do with something being sent to defaultwndproc or w/e.
Title: Re: Unwanted Beeping
Post by: Spilled on February 14, 2006, 12:40 AM
but in the proc I return 0, Like so:


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;


Am I doing soemthing wrong? Im creating it with CreateWindowEx() so i cant use WM_CHAR.... any other ideas guys?
Title: Re: Unwanted Beeping
Post by: warz on February 14, 2006, 02:06 AM
Solved here: [Win32] Unwanted beep while looking for VK_RETURN within WM_KEYDOWN (http://forum.valhallalegends.com/index.php?topic=13766.msg140681#msg140681)
Title: Re: Unwanted Beeping
Post by: Spilled on February 14, 2006, 01:16 PM
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.