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.....?
I can almost garantee I'm wrong, but the only thing I can think of is setting (int)wParam != VK_RETURN.
I even tried:
switch(message)
{
case WM_CHAR:
if((TCHAR)wParam == '\r')
break;
}
Still beeps, any other ideas?
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?
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
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).
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
I think it has something to do with something being sent to defaultwndproc or w/e.
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?
Solved here: [Win32] Unwanted beep while looking for VK_RETURN within WM_KEYDOWN (http://forum.valhallalegends.com/index.php?topic=13766.msg140681#msg140681)
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.