One alternative to using hooks would be to superclass the "edit" control wndclass, like this:
Originally Posted by zypronix
GetClassInfo() fills the supplied WNDCLASS structure with the edit control's default stuff, including its pointer to its default window procedure. You're going to switch its default window procedure function out for your own, but before you do you save the pointer to the default function so you can still call it to handle all the other stuff you expect an edit control to magically handle for you. You also give your superclass a new name and assign it some other stuff, then register it just like any other WNDCLASS structure.
/* ... */
hInst = GetModuleHandle(0);
GetClassInfo(hInst, TEXT("edit"), &wndclass);
OldWndProc = wndclass.lpfnWndProc;
wndclass.lpfnWndProc = MyEditBoxProc;
wndclass.lpszClassName = TEXT("myedit");
wndclass.hInstance = hInst;
To create an edit control which uses MyEditBoxProc, you use TEXT("myedit") for the lpClassName in your CreateWindow call instead of TEXT("edit").
LRESULT CALLBACK MyEditBoxProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
/* Catch and process keypresses here */
return CallWindowProc(OldWndProc, hwnd, msg, wparam, lparam);