Change Key

V

verenadoll

Hello NG,

i would like to change a '*' character into a '.' character in all
forms of
my project.

Maybe it is possible with PreFilterMessage or KeyboardHook. Perhaps
someone
has an example for me.

I use the Symbol MC5590, CompactFramework 3.5, WindowsMobile 6.1 and
OpenNetCF 2.3.0.21.

Regards, Verena
 
P

Paul G. Tobey [eMVP]

Usually, catching and replacing a key in every single window in an
application is what you'd call a "bad idea". Give us some background on why
you think you need to do this.

If there really is a good reason, you could certainly do it in a low-level
keyboard hook, but you'd have to hook every window (every form, every
control, etc.), in your entire application and do the replacement.
Alternatively, if you have control over the main message loop, you can do
something like this:

while (GetMessage(&msg, NULL, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
// Check for ; character and, if found, change to *.
if ( msg.message == WM_CHAR )
{
if ( msg.wParam == _T( ';' ) )
{
msg.wParam = _T( '*' );
}
}
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}

I just verified that this works as expected (in C of course), on Windows CE
5.0, so, if you do the same in managed code, you should get the same effect.

Paul T.
 
C

Chris Tacke, eMVP

Yep, an IMessageFilter implementation could do that exact same thing, and is
pretty trivial to implement (using the SDF).


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com

"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:[email protected]...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top