Tech Support > Microsoft Windows > Development Resources > Edit Subclassing
Edit Subclassing
Posted by Flzw on August 5th, 2004


Hello, I want to sublcass an Edit control so that I can catch when the user
presses the enter key
here's my subclass window proc, EditControlProc is the normal Edit window
proc.

LRESULT CALLBACK InputEditSubProc( HWND hWnd, UINT uMsg, WPARAM wParam,
LPARAM lParam)
{
char* cmd;
switch( uMsg)
{
case WM_KEYDOWN:
switch (wParam)
{
case VK_RETURN:
cmd = new char[768];
SendMessage( hWnd, WM_GETTEXT, 768, (LPARAM) cmd);
// Processing
SendMessage( hWnd, WM_SETTEXT, 0, (LPARAM) "");
delete cmd;
break;
default:
return CallWindowProc( EditControlProc, hWnd, uMsg, wParam,
lParam);
}
break;
default:
return CallWindowProc( EditControlProc, hWnd, uMsg, wParam, lParam);
}
return 0;
}


This works fine, my code is executed properly, but, whatever I return, I
still have a windows ding when I press enter (which looks like the default
edit behavior), that is not supposed to happen if I return 0 so I'm at a
loss here...


Also, is there a good and simple way to retrieve the window proc for the
EDIT control ? what I do at the moment is retrieve it when I create my first
Edit control, but this makes me check if I already have it every time I
create one. I'd like something I could run once on the application init.

Thanks


Posted by Mike H on August 5th, 2004


Add :
Case WM_CHAR
if (wParam==VK_RETURN) return 0;

The return is actually sent as a char (your ding) and as a KeyDown.

Mike H.

"Flzw" <flownz@wanadoo.fr> wrote in message
news:cet81c$98a$1@news-reader4.wanadoo.fr...


Posted by Flzw on August 6th, 2004



Thanks, works fine!




Similar Posts