DanHo
May 27th, 1999, 07:45 PM
Hi everyone,
I developed a program which intercept and translate keyboard characters to one or two other characters. I used WH_WH_GETMESSAGE system wide hook in a DLL, translate each character and SendMessage to the active focusing window. This process requires me to sometine send a BACK SPACE to the active window to erase previous displayed character and relpace it with a new character upon ensuing SendMessage of new character.
Well, this program (DLL) seems to work fine with notepad.exe, hotmail and other simple application but not with Microsoft Words. Why ? Helpppp !!!
Below is a portion of the code inside WM_GETMESSAGE callback routine ..
#define BACKSPACE 0x8
...
if (lpMsg->message == WM_CHAR)
{
// translate this character
WPARAM wOut = a2v(lpMsg->wParam, &cPrev, &cPrev1);
if (lpMsg->wParam != wOut) // yes translated
{
// erase previous (untranslated) displayed character with backspace
HWND hwFocus = ::GetFocus();
SendMessage(hwFocus, WM_KEYDOWN, VK_BACK, 0x000E0001);
SendMessage(hwFocus, WM_CHAR, BACKSPACE, 0);
SendMessage(hwFocus, WM_KEYUP, VK_BACK, 0xC00E0001);
}
lpMsg->wParam = wOut; // update new character
return CallNextHookEx(ghGetMessageHook, nCode, wParam, lParam);
}
thanks
I developed a program which intercept and translate keyboard characters to one or two other characters. I used WH_WH_GETMESSAGE system wide hook in a DLL, translate each character and SendMessage to the active focusing window. This process requires me to sometine send a BACK SPACE to the active window to erase previous displayed character and relpace it with a new character upon ensuing SendMessage of new character.
Well, this program (DLL) seems to work fine with notepad.exe, hotmail and other simple application but not with Microsoft Words. Why ? Helpppp !!!
Below is a portion of the code inside WM_GETMESSAGE callback routine ..
#define BACKSPACE 0x8
...
if (lpMsg->message == WM_CHAR)
{
// translate this character
WPARAM wOut = a2v(lpMsg->wParam, &cPrev, &cPrev1);
if (lpMsg->wParam != wOut) // yes translated
{
// erase previous (untranslated) displayed character with backspace
HWND hwFocus = ::GetFocus();
SendMessage(hwFocus, WM_KEYDOWN, VK_BACK, 0x000E0001);
SendMessage(hwFocus, WM_CHAR, BACKSPACE, 0);
SendMessage(hwFocus, WM_KEYUP, VK_BACK, 0xC00E0001);
}
lpMsg->wParam = wOut; // update new character
return CallNextHookEx(ghGetMessageHook, nCode, wParam, lParam);
}
thanks