Handling the WM_KEY events in child window ?

I have created a program which has one main window. and inside its WndProc's WM_CREATE section I create two edit windows using CreateWindow() both have the parent same window (the original window).

Now I want to handle the KeyPress event differently for the one edit Box.
So I used following code to set the different Prc for one edit Window

txtsnd = CreateWindow(TEXT("edit"),TEXT("Type Your Message Here.."),
WS_VISIBLE | WS_CHILD |ES_WANTRETURN,
50,280,400,50,
hwnd,(HMENU) 4, NULL,NULL);

SetWindowLong(txtsnd,GWL_WNDPROC,(LONG) SndWndProc);

that too inside the WM_CREATE section....


///////////////// The SndWndProc() is defined as
LRESULT CALLBACK SndWndProc(HWND hwnd,UINT msg, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT paintSt;
RECT aRect;
MessageBox(NULL,TEXT("The new window Proc."), TEXT("ERROR!!!!"),MB_OK);
switch(msg)
{
case WM_PAINT:
{
hdc = BeginPaint(hwnd,&paintSt);
GetClientRect(hwnd,&aRect);

SetBkMode(hdc,TRANSPARENT);
EndPaint(hwnd,&paintSt);

}
break;
case WM_CREATE:
SetWindowLong(txtsnd,GWL_WNDPROC,(LONG) SndWndProc);
break;
case WM_COMMAND :
{
MessageBox(NULL,TEXT("WM_COMMAND"), TEXT("WM_CMD!!"),MB_OK);
switch(LOWORD(wParam))
{
case WM_KEYUP:
MessageBox(NULL,TEXT("KEY UP"), TEXT("UP!!!!"),MB_OK);
break;
case WM_KEYDOWN:
MessageBox(NULL,TEXT("KEY DOWN"), TEXT("DOWN!!!!"),MB_OK);
break;
}
}
break;
default:
return WndProc(hwnd,msg,wParam,lParam);
}
return 0;
}

LRESULT CALLBACK WndProc(HWND hwnd,UINT msg, WPARAM wParam, LPARAM lParam)
{
// the code for WndProc
}

//// This results to the following error
error C3861: 'WndProc': identifier not found


// Now if I change the default section of the switch
return DefWindowProc(hwnd,msg,wParam,lParam);

the build succeeds .... but the program still doesnt work....

I just want to send the text in the edit box to some remote side whenever the user presses enter while typing. I have a default button but it loses focus as user starts typing something...

can anyone help me out of this ? any tutorial, book, maiterial on WIN 32 API will be of great help. I just want to learn all this heck.


Thanks,

Last edited on
Topic archived. No new replies allowed.