Hooking keypress event at runtine  
Author Message
Ankit Jain





PostPosted: Visual C# General, Hooking keypress event at runtine Top

Hi,
Having handle (hwnd) of an editbox, is there a way to register a c# function for listening keypress events. I mean hooking at runtime.

Actually, I have a native application and writing a plugin to it, requiring to listen keypress events on a particular editbox. I tried SetWindowsHookEx but it hooks on the entire window/form. I just want to listen for one editbox only. Is there any WIN32 Api using that, i can achieve the same Any pointer will be helpful.

Thanks
~ Ankit



Visual C#19  
 
 
Michael Koster





PostPosted: Visual C# General, Hooking keypress event at runtine Top

Dynamic window subclassing will work. Call the API SetWindowLong () with nIndex = GWL_WNDPROC to register a new window procedure.

Here is a sample to to do this: http://msdn2.microsoft.com/en-us/library/ms229658.aspx

Michael